读书人

100分解决错误异常:org.hibernate.id

发布时间: 2012-02-04 15:43:08 作者: rapoo

100分解决异常错误:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling s
sql server2000数据库: table:ware 有一个 主键wid 自增

hibernatepe配置文件:
<class name= "com.ll.model.Ware " table= "ware " schema= "dbo " catalog= "vod ">
<id name= "wid " type= "java.lang.Integer ">
<column name= "wid " />
<generator class= "assigned " />
</id>

报错:org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save()

将assigned改成increment类型

报错:org.hibernate.exception.SQLGrammarException: could not fetch initial value for increment generator

Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]对象名 'ware ' 无效。

将assigned改成vipId类型

报错:org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: Could not read mappings from resource: com/ll/model/Admin.hbm.xml
java.lang.NullPointerException

谁来救救我!

[解决办法]
generator class= "assigned“而你的类型type= "java.lang.Integer”这不明显的问题吗? 如果你的主键时自动增长的Int型,把你的assigned改成自动增长的Identity,assigned是自动增长的varchar型的。晕!

读书人网 >J2EE开发

热点推荐