User类定义:
@OneToMany(mappedBy = "user", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
Set pets = null;
Pet类定义:
@ManyToOne()
@JoinColumn(name = "ower_id")
User user = null;
数据库的user表和pet表通过外键ower_id关联
打印出的sql语句:
Hibernate:
/* insert edu.ustc.pet.entity.User
/ insert
into
user
(name)
values
(?)
Hibernate:
/ insert edu.ustc.pet.entity.Pet
*/ insert
into
pet
(name, ower_id)
values
(?, ?)
为什么pet表的ower_id值总是空???(应该是user的id值啊)