wood burning stoves 2.0*
The moose likes Object Relational Mapping and the fly likes Hopefully an easy problem with Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hopefully an easy problem with Hibernate" Watch "Hopefully an easy problem with Hibernate" New topic

Hopefully an easy problem with Hibernate

Shak Smith

Joined: Feb 19, 2010
Posts: 12
Basically what I want to do is the following;
To be able to create an Event with three Speakers .
Speakers table has an event_id column which is NULL and NO Default value(NULL).
The only way I can do the insertions is by setting insert="false" update="false" in the speakers hbm.
I want to be able to update the speaker's event_id after it was inserted. So leaving the update="false" doesn't work for me.
The problem is that if I change the update to "true" then I'm not able to insert Events or Speakers anymore and I get the following error:
Repeated column in mapping for entity: com.manning.hq.ch04.Speaker column: event_id (should be mapped with insert="false" update="false")
How can I achieve that?

<hibernate-mapping package="com.manning.hq.ch04">
<class name="Event" table="events">
<id name="id" column="uid" type="long">
<generator class="native" />
<property name="name" type="string" />
<set name="speakers" cascade="save">
<key column="event_id" not-null="true" />
<one-to-many class="Speaker" />

<hibernate-mapping package="com.manning.hq.ch04">
<class name="Speaker" table="speakers">
<id name="id" column="uid" type="long">
<generator class="native" />
<many-to-one name="event" class="Event" column="event_id" insert="false" update="false"/>
<property name="name" type="string" />

I agree. Here's the link: http://aspose.com/file-tools
subject: Hopefully an easy problem with Hibernate
Similar Threads
update while doing save in hibernate
Indexed Collections
Please explain me the hibernate generated sql queries in console
Lazy loading not working as expected
SQLGrammarException: could not get next sequence value