User.java
package com.itheima.a_hello;public class User {
private Integer id;
private String name;
private String password;
public Integer getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
相应的映射文件位置:JavaBean同包
相应的映射文件名称:JavaBean同名
相应的映射文件扩展名:*.hbm.xml
具体内容如下:
先添加约束
我们只要约束的代码,为了引入。约束代码如下: <!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">