hibernate + spring 不能写入数据库,查询就OK

发表于2008年07月30日 17:25 阅读(4) 评论(0)

 

1.
<id name="id" type="java.lang.Integer">
            <column name="id" />
            <generator class="native" />
</id>

修改native 为 assigned ,increment,identity  ~~~这个属性可选的值真系太多,不太了解其具体的使用,只知道它会影响hibernate生成的SQL语句的内容.

有时
Hibernate: insert into testhibernate.student (name, sex, address, interesting) values (?, ?, ?, ?)
也会输入主键
Hibernate: insert into testhibernate.student (name, sex, address, interesting,id) values (?, ?, ?, ?,?)

2.
修改 表名dao类中的 方法,加上  getHibernateTemplate().flush()

///////////////////////////////////////////////////////////////////////////////
以上方法都不行

3.
在 hibernate 的 cfg文件中加入配置
<property name="connection.autocommit">true</property>


OK~~~~~~~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章