This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Persisting linked-list using Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Databases » Object Relational Mapping
Reply Bookmark "Persisting linked-list using Hibernate" Watch "Persisting linked-list using Hibernate" New topic
Author

Persisting linked-list using Hibernate

Raghvendra Singh
Greenhorn

Joined: Jan 23, 2011
Posts: 1
Check the object model attached. Parent has reference to firstSeqChild and then onward the seqChild object keeps the reference to next seqChild, hence creating a linked list.

Problem:
Hibernate saveOrUpdate fails with StackOverflow exception if the parent has approx 300 transient seqChildren (due to cascade save effect).
Is there anyway to bypass this problem? I am expecting this seqChildren list to be in thousands in actual implementation.

Another obvious thought I had was to convert the parent seqChild relationship to a "one to many" and use sorted set based on a new index column. but that does not server the purpose becuase an object can be inserted in between the chain (linked list). "it is mandatory for every seqChild to know its preceeding and follwoing seqChild". Design changes, that does not contradict this rule are also welcome.

Relevant code ..

Parent.java


SeqChild.java

Parent.hbm.xml

SeqChild.hbm.xml

Please ask for any additional information required .. Thanks for your help ..



[Thumbnail for Model.jpg]

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Persisting linked-list using Hibernate
 
Similar Threads
Parent-Child Mapping with Hibernate 2.0
Parent-Child Confusion ....
Request processing failed; nested exception is org.springframework.beans.InvalidPropertyException:
polymormsim related demos
Replacing *.hbm.xml files with @Annotations.