我使用 Eclipse Hibernate Tools 从我的数据库开始创建域类,并且需要添加 JPA 注释。
有没有办法添加注释?可能使用 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;
}
...