1
生成基本對象ID的名字我有我的所有實體基本對象:如何在Hibernate中
@MappedSuperclass
public class BaseObject {
@Id
@GeneratedValue
@Column(name = "entity_id")
private Long id;
/**
*
* @return true if the entity hasn't been persisted yet
*/
@Transient
public boolean isNew() {
return id == null;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
的問題是,我需要ID unicate名。
像這樣:
user_id, car_id, cat_id
我不知道,怎麼辦呢,你能幫幫我嗎?
它可能會覆蓋子類中的加號Column(name = "entity_id")
?
public class User extends BaseObject
public class Car extends BaseObject
public class Cat extends BaseObject
你能舉個例子嗎?謝謝你,兄弟。 – clougioc
該鏈接有例子...但我會給一個... –
工作正常,謝謝你的幫助。 – clougioc