• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Kumar Raja
Ranch Hand
Posts: 558
2
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any thoughts on this question
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic