我有许多需要对 POJO 进行逆向工程的数据库表。我已经创建了裸 POJO 以及 cfg.xml 文件:
简单的 POJO:
public class AddressType implements java.io.Serializable {
private long addressId;
private char addressType;
private String addressDescription;
}
简单的cfg.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.mycompany.model.Addytyp" table="ADDYTYP" schema="XX" catalog="BANANA">
<comment>Address Types</comment>
<id name="addressType" type="char">
<column name="ADDRESS_TYPE" length="1" />
<generator class="assigned" />
</id>
<property name="addressId" type="long">
<column name="ADDRESS_ID" precision="10" scale="0" not-null="true">
<comment>Address ID</comment>
</column>
</property>
<property name="addressDescription" type="string">
<column name="ADDRESS_DESCRIPTION" length="25" not-null="true">
<comment>Address Decription</comment>
</column>
</property>
</class>
</hibernate-mapping>
我想知道的是,是否有一种设置或工具可以对 POJO 进行反向工程,并将列和 ID 信息作为 POJO 中的注释而不是在单独的文件中?例如:
带注释的简单 POJO:
@Table(name="ADDYTYP")
public class AddressType implements java.io.Serializable {
@Id
@Column( name="ADDRESS_ID", precision=10, scale=0, nullable=true)
private long addressId;
@Column(name="ADDRESS_TYPE", length=1)
private char addressType;
@Column( name="ADDRESS_DESCRIPTION", length=25 nullable=true)
private String addresDescription;
}
有人知道可以执行此操作的设置或工具吗?