Orphan removal with RequestFactory

68 views
Skip to first unread message

bond

unread,
Jul 16, 2012, 11:23:46 AM7/16/12
to google-we...@googlegroups.com
Hi guys,
I'm using Hibernate + Gw's Request factory. I've a problem using a class with a list of object like this:

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, orphanRemoval = true)
private Set<ScadenzaPagamento> scadenze = new LinkedHashSet<ScadenzaPagamento>();

It's seems that orphanRemoval don't work with Request Factory as show in this post: https://groups.google.com/forum/?fromgroups#!topic/google-web-toolkit/oWJRhnUHAYc.

Before using request Factory I used Gwt + Gilead and orphanRemoval worked great!!

Any idea in order to resole this problem?

Thanks very much!

Best regards

Daniele Renda

Jens

unread,
Jul 16, 2012, 12:01:48 PM7/16/12
to google-we...@googlegroups.com
And whats actually your problem? Or do you have the exact same problem as in the linked discussion?

How is your setter implemented? In the linked discussion the problem is pretty much that the setter is implemented like

public void setChildList(List childs) {
  //dereferences the original (hibernate) list which could cause the exception on commit.
  this.childs = childs; 
}

instead of

public void setChildList(List childs) {
  //keep the (hibernate) list so hibernate can track its changes
  this.childs.clear();
  this.child.addAll(childs);
}

--- J.

bond

unread,
Jul 16, 2012, 12:08:13 PM7/16/12
to google-we...@googlegroups.com
Hi,
I'm in this scenario.

There is the class A that has a list of object of class B.

I've a Ui where I can add and remove (for every object A) object B. Where I remove object B from A and then persist, in my database is removed the association from A -> B but the entity B is still in the table!!! So, seems that orphanremoval don't work as expected.

I've the default implementation of setter and getter of A and B classes.

Thank very much

Daniele
Reply all
Reply to author
Forward
0 new messages