【发布时间】:2015-08-31 10:46:51
【问题描述】:
我有两个具有多对一关系的对象:
对象 1:
@Entity
@Table(name=”Person”)
public class Person {
Long id;
String name;
String surname;
… // other fields
@NotFound(action=NotFoundAction.IGNORE)
@ManyToOne @JoinColumn(name = "groupId")
Group group;
....all the getters and setters…
}
对象 2:
public class Group {
@Id
@Column
Long groupId;
@Column
protected String groupName;
@Column(precision = 15, scale = 0)
protected long exampleFieldId;
...rest of code....
}
Person 类中的字段“组”可以为空。如何确定从数据库或“NotFound”注释中获取空值的位置?
这种情况可能是以下情况:数据库级别的用户可以访问一组有限的组。
【问题讨论】:
标签: spring hibernate annotations many-to-one