merge « Cascade « JPA Q&A

1. How can I ignore cascade when calling persist/merge

How can I ignore cascade saving/updating when calling persist(..)/ merge(..) without removing cascade annotation?

2. Hibernate in case of cascade(All,merge,persist)

HEllo I am using two way association... i.e. oneTomany and manyToone... Case 1 > On oneTomany mapping I had set cascade=cascadeType.persist and cascade=cascadeType.merge... When I tried to save parent object which also includes child's set with session.persist only parent object got persist not child collection. Is this a how hibernate works? or this operation should persist child as well. Case 2> ...

3. Cascade on merge

Hi Everyone, I have some trouble with cascading on a one to many relationship with Hibernate 3.5.1-Final. It is a One To Many Relationship between Faculty 1 ---- N Group. The cascade works well on .save() method call. But it fails on .merge() This is my testcase: Code: @Test public void shouldCascadeWithGroupsWithAlreadyExistingFaculty() ...

4. Unidirection Mana-TO-Many - Merge doestn work - NO Cascade

Hi, I had a similar problem but I found a workaround (not beautiful but still) like this: public void setAssignedUsers (Set users) { if( this.assignedUsers == null) ; this.assignedUsers = new HashSet(); } this.assignedUsers .clear(); this.assignedUsers .addAll(children); } My problem is fully described at:"Collection update (merge) problem" Please, let me know if that fixed your problem. Regards / daiv