Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

List for 1:many

G Nguyen
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am trying to implement a 1:many bidirection association using a list,
something like

ID number primary key

ID number primary key,
PARENT_ID number, references PARENT,

The hibernate mappings for both are set up, and I can cascade insert (parent mapping has list with cascade="all") the CHILD record by on the parent record. Question is, if there are multiple children, eg. order=0,1,2,3 and I would like to delete one, eg. CHILD_ORDER=2. List.remove(index) supports this functionality. But do I have to go back and reorder every child record with CHILD_ORDER > 2? Hibernate doesn't seem to do it automatically when I call on the parent object. If I leave a hole in the list, Hibernate still thinks there are 4 children (it does a select max(CHILD_ORDER)+1 to get the number of children.
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!