在关系映射配置文件中这样写:
<class name="Test" table="test">
<id name="id">
<generator class="native"></generator>
</id>
</class>
测试的时候报错,提示是语法错误,查看hibernate生成的建表语句,为:
create table test (id integer not null identity, primary key (id))
好像是identity出错,我的问题是:为什么会生成identity型的,不应该是auto_increment吗?
<class name="Test" table="test">
<id name="id">
<generator class="native"></generator>
</id>
</class>
测试的时候报错,提示是语法错误,查看hibernate生成的建表语句,为:
create table test (id integer not null identity, primary key (id))
好像是identity出错,我的问题是:为什么会生成identity型的,不应该是auto_increment吗?
解决方案 »
- 在hibernate当中,调用了session.close()后到底会不会清空缓存?谢谢!
- web.xml 的配置问题
- JAVA 如何实现HTTP的POST方式通讯,以及HTTPS方式传递
- JSp 项目连接数据库 的问题。。
- Struts中 修改删除记录
- weblogic 总是报这种错误,然后连接数据库就断开,该在哪儿修改 谢谢!新年愉快
- 在HQL中如何使用计算列
- hibernate中session的管理问题?
- 请问j2ee中自带的Application Server比weblogic有什么不同?是否能代替weblogic?
- 模糊中
- com.casinocity.bean.GameCategory cannot be cast to java.lang.Comparable
- 讨论一下报表系统的数据处理架构,怎样做到高效率
加上这个试下 auto_increment
<id name="id">
<generator class="identity"></generator>
</id>
</class>
改成这样就好了
需要在oracle中创建一个hibernate_sequence序列
是啊,理论上对于mysql数据库它就应该生成auto_increment型的id啊,但是,它却生成identity型的,所以mysql数据库就报错,说语法错误。
这样和使用native一样的啊,最后生成的语句都是create table test(id integer identity not null,primary key(id));
问题就是不能生成identity型的id,而应该是auto_increment才可以。