aspose file tools*
The moose likes Object Relational Mapping and the fly likes Repeated updates on EVENT table, in Hibernate one to many mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Repeated updates on EVENT table, in Hibernate one to many mapping" Watch "Repeated updates on EVENT table, in Hibernate one to many mapping" New topic
Author

Repeated updates on EVENT table, in Hibernate one to many mapping

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 516
    
    2

Hi All,

I have an Event.hbm.xml



Person.hbm.xml


The above examples are taken from associations.

I populated Events and Persons and now trying to add an event to Person in two different unit of works, as the example given in link, only that I changed the query.



Now I'm trying to associate person and events as below (Assume that addEventsToPersons has the above logic)

em.addEventsToPersons(1,1);
em.addEventsToPersons(1,2);
em.addEventsToPersons(1,3);
em.addEventsToPersons(1,4);

The association is working fine, but what I noticed is the below sequence of SQL



As you notice, the number of times I'm trying to add events to persons, the execution of Hibernate: update LEARN.EVENT set EVENT_TITLE=?, EVENT_DATE=? where EVENT_ID=? is increasing.

and also, why Hibernate: delete from LEARN.PERSON_EVENT where PERSON_ID=? for the first association. Why should the record be deleted and then added back again.

Please advise.
is being executed m


Regards
KumarRaja

Kumar Raja
Ranch Hand

Joined: Mar 18, 2010
Posts: 516
    
    2

Any thoughts on this question
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Repeated updates on EVENT table, in Hibernate one to many mapping
 
Similar Threads
Making a detached Object persist
inverse=true in many-to-many doubt
Mapping Exception
Mapping Resource exception
Hibernate hql list filter