Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. @DatabaseTable(tableName = "Threads")
  2. public class Thread {
  3.  
  4. @DatabaseField(id = true)
  5. private String subject;
  6.  
  7. @DatabaseField(foreign = true, foreignAutoRefresh = true)
  8. public User user = new User();
  9.  
  10. public void setSubject(String subject) {
  11. this.subject = subject;
  12. }
  13.  
  14. public String getSubject() {
  15. return subject;
  16. }
  17. }
  18.  
  19. @DatabaseTable(tableName = "Users")
  20. public class User {
  21. @DatabaseField(id = true)
  22. private String nickName;
  23. @DatabaseField
  24. private String password;
  25. @DatabaseField
  26. private String email;
  27.  
  28. @ForeignCollectionField(eager = false)
  29. public Collection<Thread> threads = new ArrayList<Thread>();
  30.  
  31. public void setNickName(String nickName) {
  32. this.nickName = nickName;
  33. }
  34.  
  35. public String getNickName() {
  36. return nickName;
  37. }
  38.  
  39. public void setPassword(String password) {
  40. this.password = password;
  41. }
  42.  
  43. public String getPassword() {
  44. return password;
  45. }
  46.  
  47. public void setEmail(String email) {
  48. this.email = email;
  49. }
  50.  
  51. public String getEmail() {
  52. return email;
  53. }
  54. }
  55.  
  56. Exception in thread "main" java.lang.IllegalArgumentException: No fields have a DatabaseField annotation in class java.lang.Thread
  57.  
  58. JdbcConnectionSource connectionSource = new JdbcConnectionSource(
  59. databaseUrl);
  60. Dao<Board, String> boardDAO = DaoManager.createDao(
  61. connectionSource, Board.class);
  62. Dao<Category, String> categoryDAO = DaoManager.createDao(
  63. connectionSource, Category.class);
  64.  
  65. Dao<Thread, String> threadDAO = DaoManager.createDao(
  66. connectionSource, Thread.class);
  67.  
  68. Dao<User, String> userDAO = DaoManager.createDao(
  69. connectionSource, User.class);
  70.  
  71.  
  72.  
  73. TableUtils.createTable(connectionSource, Board.class);
  74. TableUtils.createTable(connectionSource, Category.class);
  75. TableUtils.createTable(connectionSource, Thread.class);
  76. TableUtils.createTable(connectionSource, User.class);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement