【发布时间】:2018-05-19 13:29:01
【问题描述】:
大家好!
我遇到了一个奇怪的问题。我正在尝试创建一个简单的数据库模式。但是 hibernate 为在 *-to-many 表中引用 id-columns 的列创建了额外的序列。
我用
@Id, @Column(columnDefinition = "serial"), @GeneratedValue(strategy = GenerationType.IDENTITY)
为BIGSERIAL 类型创建序列(但我不希望休眠将外键设为BIGSERIAL 的列)。
我的实体有这样的结构
@Entity
public class PropertyItem {
//id's here ...
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "property_id")
private Property property;
//getters and setters ...
}
@Entity
public class Property {
//id's here ...
@OneToMany(mappedBy = "property")
private List<PropertyItem> propertyItems;
//getters and setters ...
}
请帮我避免这种情况:(
谢谢你????
【问题讨论】:
标签: java hibernate orm hibernate-mapping