Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Repeated column in mapping for entity: insert="false" update="false'

 
Sandeep Vaid
Ranch Hand
Posts: 392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Item - Bid bidirecitonal association

I am getting the following error :

 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are going to map a field more than once in an object you'll nee to do as the error message says and define one of the mappings as read only.
 
Arun Kumarr
Ranch Hand
Posts: 661
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you set the inverse relationships correctly.
 
Hsitas Hickory
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This also happens when the column name is repeated.

For example in the mapping hbm file,

<property name="school" column="schoolname" type="string"/>
<property name="grade" column="schoolname" type="string"/>

Here since the column ="cname" is used twice one for the school and one for the grade, this error happens


Initial SessionFactory creation failed.org.hibernate.MappingException: Repeated column in mapping for entity: Student column: schoolname (should be mapped with insert="false" update="false")
Exception in thread "main" java.lang.ExceptionInInitializerError
at HibernateUtil.<clinit>(HibernateUtil.java:41)
at Main.main(Main.java:20)
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: Student column: schoolname (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 HibernateUtil.<clinit>(HibernateUtil.java:37)
... 1 more
Java Result: 1


change it to

<property name="school" column="schoolname" type="string"/>
<property name="grade" column="grade" type="string"/>

 
vasu chowdary
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
declare insert="false" and update="false" in your mapping file(may be for your collection element) then try...............
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic