A.唯一外键关联
DDL:
1.CREATE TABLE user (2. id INT(11) NOT NULL auto_increment PRIMARY KEY,3. name VARCHAR(100) NOT NULL default '',4. room_id INT(11)5.);6.7.CREATE TABLE room (8. id INT(11) NOT NULL auto_increment PRIMARY KEY,9. address VARCHAR(100) NOT NULL default ''10.);
User.java
1.package com.hb3.pack_02.model;2.3.public class User {4. 5. private Integer id;6. private String name;7. private Room room;8.9. public User() {10. }11. 12. public Integer getId() {13. return id;14. }15. public void setId(Integer id) {16. this.id = id;17. }18. public String getName() {19. return name;20. }21. public void setName(String name) {22. this.name = name;23. }24. public Room getRoom() {25. return room;26. }27. public void setRoom(Room room) {28. this.room = room;29. }30.}
以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索private
, null
, integer
, public
, name
Room
,以便于您获取更多的相关知识。
时间: 2024-11-18 06:42:11