bernate3.6之前的版本使用Annotation,还需要下载Annotation库,需要添加ejb3-persistence.jar hibernate-annotations.jar hibernate-commons-annotations.jar,而获得SessionFactory必须以下这样写
Configuration cfg=new AnnotationConfiguration();
SessionFactory s=cfg.configure().buildSessionFactory();
在hibernate3.6的这个版本中,Annotation类库集成到了hibernate3.6,所以不在需要添加hibernate-annotations.jar hibernate-commons-annotations.jar等类库了。但是必须添加hibernate-jpa-2.0-api-1.0.0.Final.jar。
hibernate 3.6要获取一个SessionFactory,我可以直接像用xml来配置实体与数据库表的映射关系那样。代码如下:
Configuration cfg=new Configuration();
SessionFactory s=cfg.configure().buildSessionFactory();
[转自]http://hi.baidu.com/pgfepdcwge/blog/item/9c15fab7d4449f628ad4b24a.html