Announcement Announcement Module
Collapse
No announcement yet.
Roo setters unsafe if orphanRemoval=true Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo setters unsafe if orphanRemoval=true

    The way roo generates getters and setters is risky.
    I added orphanRemoval=true over a Collection of childrens in my parent entity, and in this way I can delete the parent entity and all his children will also be deleted (otherwise, as expected, the deletion will fail on a constraint violated foreign key between them).
    The problem is that if I try to make an update to the parent now, the exception:

    Code:
    org.hibernate.HibernateException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:
    is triggered.
    Wouldnt it be better if roo's setter was made like this:

    Code:
    public void setChildren(Collection<Child> children) {
        this.children.clear();
        this.children.addAll(children);
    }
    Thanks all,
    TD

  • #2
    I trusted something to be simple for once, but I was mistaken. Changing the setter has no effect, that exception is still raised if you add orphanRemoval=true over a Collection in roo....

    Comment

    Working...
    X