4
我使用Eclipse Hibernate Tools從我的數據庫開始創建域類,並需要添加JPA註釋。如何使用Hibernate工具生成帶註釋的域對象
有沒有添加註釋的方法?可能與reveng.xml和逆向工程?這應該怎麼做?
生成的域代碼:
public class Country implements java.io.Serializable {
private long id;
private String description;
private String identifier;
private String futureuse;
private Set accounts = new HashSet(0);
public Country() {
}
public Country(long id, String description, String identifier) {
this.id = id;
this.description = description;
this.identifier = identifier;
}
...
所需的代碼:
@Entity
@Table(name = "COUNTRY")
public class Country implements java.io.Serializable {
@Id
@Column(name="CNTR_ID")
private Long id;
@Column(name="CNTR_FUTUREUSE")
private String futureUse;
@Column(name="CNTR_IDENTIFIER")
private String identifier;
@Column(name="CNTR_DESCRIPTION")
private String description;
private Set accounts = new HashSet(0);
public Country() {
}
public Country(long id, String description, String identifier) {
this.id = id;
this.description = description;
this.identifier = identifier;
}
...