第一次Hibernate,总结了如下几点。
1. 使用Hibernate Synchronizer的时候,是否生成相应的DAO类由每个表的mapping中的
<meta attribute="sync-DAO">false</meta>决定。
2. 持久化对象一般这样写。
Configuration cfg = new Configuration();
SessionFactory factory = cfg.configure().buildSessionFactory();
其中configure()命令加载hibernate.cfg.xml文件,如没有,则从类路径中加载hibernate.properties。
3. 每个xml的头申明也很重要。
如,<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
mapping错为Configuration,或者3.0和2.0的混淆都是不可以的。

