-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Moving an item from one ordered list to an other
PostPosted: Wed Jan 06, 2010 12:58 pm 
Newbie

Joined: Mon Dec 25, 2006 5:05 pm
Posts: 5
Hi

I have an entitity with a following mapping:
Code:
   @OneToMany(cascade=CascadeType.ALL, fetch = FetchType.EAGER)
   @Cascade( { org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN } )
   @IndexColumn(name = "position", base = AppInfo.BASE)
   @JoinColumn(name="parent", nullable=false)
   private List<MenuItem> children;
   public List<MenuItem> getChildren() {
      return children;
   }

   public void setChildren(List<MenuItem> children) {
      this.children = children;
   }
   
   @ManyToOne()
   @JoinColumn(name="parent", insertable=false, updatable=false, nullable=false)
   private MenuItem parent;
   public MenuItem getParent() {
      return parent;
   }


If I want to move a child element to a different node, different kind of problems appear:
1. If I only adds the element to the new list: the original list will have a gap in the ordering, and will be a null element there
Code:
list.add(list.indexOf(target),insertee);

2.If I delete the element from the old list and then try to add: I get the following exception "org.hibernate.ObjectDeletedException: deleted entity passed to persist"
Code:
list.add(list.indexOf(target),insertee);
origList.remove(insertee);

or this behaves the same:
Code:
origList.remove(insertee);
list.add(list.indexOf(target),insertee);


any tips?

Thanks:
Bence


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.