JAVA基础(Hibernate注释配置方法)
在Hibernate3.2中,引入了Java5的一个新特性,即注释配置。简单来说就是丢弃*.hbm.xml文件,在POJO类中做相应的配置,完成Hibernate的映射。的基本配置如下:
导入javax . persistence . column;
导入javax . persistence . entity;
导入javax . persistence . generated value;
导入javax . persistence . generation type;
导入javax . persistence . id;
导入javax . persistence . table;
@ Entity
@ Table(name = " User ")
public class User {
@ Id
@ generated value(strategy = generation type。AUTO)
private int id;
@ Column(name = " userName ")
私有字符串名称;
@ Column(name = " user password ")
私有字符串密码;
getter和setter...
}
0条评论