1.Set映射
DDL:
1.CREATE TABLE user (2. id INT(11) NOT NULL auto_increment PRIMARY KEY,3. name VARCHAR(100) NOT NULL default ''4. );5.6.CREATE TABLE email (7. id INT(11) NOT NULL,8. address VARCHAR(100) NOT NULL9.);
User.java
1.package com.hb3.pack_11.model;2.3.import java.util.Set;4. 5.public class User {6. 7. private Integer id;8. private String name;9. private Set<String> emails;10. 11. public User() {12. }13. 14. public Integer getId() {15. return id;16. }17. public void setId(Integer id) {18. this.id = id;19. }20. public String getName() {21. return name;22. }23. public void setName(String name) {24. this.name = name;25. }26. public Set<String> getEmails() {27. return emails;28. }29. public void setEmails(Set<String> emails) {30. this.emails = emails;31. }32. public void addEmail(String email) {33. this.emails.add(email);34. }35. public void removeEmail(String email) {36. this.emails.remove(email);37. }38.}
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索string
, this
, public
, email
, name
void
,以便于您获取更多的相关知识。
时间: 2024-10-31 12:53:51