以前使用MyEclipse4.1生成Hibernate映射文件的时候,只生成一个POJO文件
例如 对应 user表中有id name password 两个字段 id为自动编号
生成映射文件user.hbm.xml为
[code] <hibernate-mapping>
<class name= "tuser.Tuser " table= "t_user ">
<id name= "id ">
<generator class= "increment "/>
</id>
<property name= "name "/>
<property name= "password "/>
</class>
</hibernate-mapping> [/code]
而使用MyEclipse5.5后映射文件变为了,貌似使用了主键的方式进行映射
[code] <hibernate-mapping>
<class name= "tuser.Tuser " table= "t_user " schema= "dbo " catalog= "HAHANews ">
<composite-id name= "id " class= "t_user.TUserId ">
<key-property name= "id " type= "java.lang.Integer ">
<column name= "ID " />
</key-property>
<key-property name= "name " type= "sring ">
<column name= "name " length= "10 " />
</key-property>
<key-property name= "password " type= "sring ">
<column name= "password " length= "10 " />
</key-property>
</composite-id>
</class>
</hibernate-mapping> [/code]
并且生成两个POJO文件(可能不这样称呼,但我是这样理解的 呵呵)
User.java为
================================
[code]public class Tuser implements java.io.Serializable {
private TuserId id;
public Tuser () {
}
public Tuser (TuserId id) {
this.id = id;
}
public TuserId getId() {
return this.id;
}
public void setId(TuserId id) {
this.id = id;
}
}[/code]
UserId.java为
================================
[code]public class TuserId implements java.io.Serializable {
private Integer id;
private String name;
private String password;
…………省略get和set方法…………[/code]