Hibernate 映射文件报错!

这是我配置的映射文件

<class name="entity.Backmoney" table="backmoney">
 <id name="code" type="java.lang.String">
  <column name="code" />
  <generator class="assigned" />
 </id>

----------------------------------------------------------------------------

我数据库这个表里面的主键是Varchar2类型的! 我想自定义设置主键!

运行的时候出错了!

Exception in thread "main" org.hibernate.MappingException: Repeated column in mapping for entity: entity.Backmoney_detail column: code (should be mapped with insert="false" update="false")
 at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:652)
 at org.hibernate.mapping.PersistentClass.checkPropertyColumnDuplication(PersistentClass.java:674)
 at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:696)
 at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:450)
 at org.hibernate.mapping.RootClass.validate(RootClass.java:192)
 at org.hibernate.cfg.Configuration.validate(Configuration.java:1102)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1287)
 at Test.Test.test1(Test.java:46)
 at Test.Test.main(Test.java:17)

 这个问题怎么解决 大家帮忙看看~

3个回答

[code="java"]


seq_backmoney
START WITH 1

[/code]

这样试试

试试。

" entity.Backmoney_detail column: code (should be mapped with insert="false" update="false") ",所以在class配置中加上insert="false" update="false" :
[code="xml"]





[/code]

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐