• Post Reply Bookmark Topic Watch Topic
  • New Topic

List for 1:many  RSS feed

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 session.save() 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 session.save() 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.
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!