w272242934
2012-08-08 15:58
浏览 254
已采纳

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条回答 默认 最新

  • foohsinglong 2012-08-08 16:22
    已采纳

    [code="java"]


    seq_backmoney
    START WITH 1

    [/code]

    这样试试

    已采纳该答案
    打赏 评论
  • cuiran 2012-08-08 16:12

    试试。

    打赏 评论
  • liuyinhuan0409 2012-08-08 16:15

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





    [/code]

    打赏 评论

相关推荐 更多相似问题