Wayne,

I think I've found the answer to the mystery.  The solution you pointed out 
from the tutorial wasn't working for me because java.util.List.remove() wasn't 
implemented for the backing List in Hibernate's PersistentBag at runtime.

I found in the Hibernate docs that collections can wind up being mapped to all 
kinds of things in Hibernate--apparently not all of them supporting remove().  
By adding an @OrderBy annotation to my @OneToMany in my Entity as shown below I 
can coerce Hibernate to use a List collection that supports remove()--and I 
wanted the sort anyway:


  |     @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy 
= "project")
  |     @OrderBy("date")
  |     public List<Timecard> getTimecard() {
  |             return this.timecard;
  |     }
  |     public void setTimecard(List<Timecard> timecard) {
  |             this.timecard = timecard;
  |     }
  | 

This list is what I set my @DataModel to in my entity manager code, so that's 
why all this Hibernate stuff is relevant.

So this is what works for me now:


  | public void delete() {
  |        tc = em.merge(tc);  // needed or I get exceptions about unattached 
objects
  |        em.remove(tc);  // no further issues here after @OrderBy in entity
  |        tcList.remove(tc);  // clean up in-memory @DataModel list
  |        projectHome.getInstance().getTimecard().remove(tc); // remove from 
in-memory Entity list for response page render
  |        tc=null;
  | }
  | 

Greg

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4035800#4035800

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4035800
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to