日期:2014-05-18  浏览次数:20709 次

初学hibernate,Hibernate Synchronizer这个插件感觉有点问题,急死了!老是有错误
我用hibernate   synchronizer按照网上的例子做了一个例子,运行了n天还是没有运行起来
这是我的hbm.xml文件
<?xml   version= "1.0 "?>
<!DOCTYPE   hibernate-mapping   PUBLIC
"-//Hibernate/Hibernate   Mapping   DTD//EN "
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd "   >

<hibernate-mapping   package= "edu.yzu ">
<class
name= "Wahaha "
table= "wahaha "
>
<meta   attribute= "sync-DAO "> true </meta>
          <id   name= "Id "   type= "Integer "   column= "id ">
        <generator   class= "sequence "/>
          </id>

<property
name= "Username "
column= "username "
type= "string "
not-null= "false "
length= "10 "
/>
<property
name= "Password "
column= "password "
type= "string "
not-null= "false "
length= "10 "
/>


</class>
</hibernate-mapping>
下面的是cfg.xml
<?xml   version= "1.0 "   encoding= "utf-8 "?>
<!DOCTYPE   hibernate-configuration
        PUBLIC   "-//Hibernate/Hibernate   Configuration   DTD//EN "
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd ">
<hibernate-configuration>
<session-factory>
<!--   local   connection   properties   -->
<property   name= "hibernate.connection.url ">
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Mydb
</property>
<property   name= "hibernate.connection.driver_class ">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<property   name= "hibernate.connection.username "> sa </property>
<property   name= "hibernate.connection.password "> guolei </property>
<!--   property   name= "hibernate.connection.pool_size "> </property   -->
<!--   dialect   for   Microsoft   SQL   Server   -->
<property   name= "dialect ">
org.hibernate.dialect.SQLServerDialect
</property>
<property   name= "hibernate.show_sql "> false </property>
<property   name= "hibernate.transaction.factory_class ">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping   resource= "edu/yzu/Wahaha.hbm.xml "   />
</session-factory>
</hibernate-configuration>
最后测试时这个地方老是有问题
_RootDAO.initialize(); /就是这个地方
WahahaDAO   persondao   =   new   WahahaDAO();
Wahaha   a=new   Wahaha();
a.setPassword( "gd ");
a.setUsername( "gd ");

/*SessionFactory   sf   =   new   Configuration().configure().buildSessionFactory();
    Session   sess   =   sf.openSession();
    Transaction   tx   = &