-->
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.  [ 3 posts ] 
Author Message
 Post subject: ManyToMany Cascading problems
PostPosted: Thu Jul 17, 2008 11:52 am 
Newbie

Joined: Fri Jun 20, 2008 4:47 am
Posts: 5
Hi,

I've got a collection of users and a collection of usergroups.
There is a connection between these two: one user is member of many groups and one group has many members.

In this example I have two groups and two users, each belonging to either group.

When I delete one user, instead of just deleting the user and the corresponding entries in the join table, it starts deleting almost everything regarding this user (delete user 1 => delete from join table => delete groups user was in => delete all users in all those groups => ...).

How can I set the Cascades so that the entries in xb_user and xb_user_memberof are deleted, but not all xb_user_groups etc...?

Thanks,
Brecht

Hibernate version: 3.2.6.ga

Mapping documents:
Code:

@Entity
@Table(name = "xb_user", uniqueConstraints = @UniqueConstraint(columnNames = "user_name"))
public class XbUser implements java.io.Serializable {

   private Integer userId;
   private String userName;
   private Set<XbUserGroup> xbUserGroups = new HashSet<XbUserGroup>(0);
   
   public XbUser() {
   }

   public XbUser(String userName) {
      this.userName = userName;
   }

   
   @Id
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "user_id", unique = true, nullable = false)
   public Integer getUserId() {
      return this.userId;
   }

   public void setUserId(Integer userId) {
      this.userId = userId;
   }

   @Column(name = "user_name", unique = true, nullable = false, length = 45)
   public String getUserName() {
      return this.userName;
   }

   public void setUserName(String userName) {
      this.userName = userName;
   }

   @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
   @JoinTable(name = "xb_user_memberof", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_group_id", nullable = false, updatable = false) })
   public Set<XbUserGroup> getXbUserGroups() {
      return this.xbUserGroups;
   }

   public void setXbUserGroups(Set<XbUserGroup> xbUserGroups) {
      this.xbUserGroups = xbUserGroups;
   }

}



Code:
@Entity
@Table(name = "xb_user_group")
public class XbUserGroup implements java.io.Serializable {

   private Integer id;
   private String name;
   private Set<XbUser> xbUsers = new HashSet<XbUser>(0);

   public XbUserGroup(String name) {
      this.name = name;
   }

   
   @Id
   @GeneratedValue(strategy = IDENTITY)
   @Column(name = "id", unique = true, nullable = false)
   public Integer getId() {
      return this.id;
   }

   public void setId(Integer id) {
      this.id = id;
   }

   @Column(name = "name", nullable = false)
   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "xbUserGroups")
   public Set<XbUser> getXbUsers() {
      return this.xbUsers;
   }

   public void setXbUsers(Set<XbUser> xbUsers) {
      this.xbUsers = xbUsers;
   }
}



Code between sessionFactory.openSession() and session.close():
Code:
XbUser user = getEntityManager().find(XbUser.class, userID);
         getEntityManager().remove(user);


Name and version of the database you are using:
MySQL 4.something

Debug level Hibernate log excerpt:
Code:
DEBUG - opened session at timestamp: 12163094518
DEBUG - begin
DEBUG - opening JDBC connection
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@1f2a9da [managed: 5, unused: 4, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@182b9b5)
DEBUG - current autocommit status: true
DEBUG - disabling autocommit
INFO  - HandleRequest: Users
INFO  - HandleAdminRequest: Retrieving data from database
DEBUG - loading entity: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbuser0_.user_id as user1_41_0_, xbuser0_.create_date as create2_41_0_, xbuser0_.global_right as global3_41_0_, xbuser0_.last_login as last4_41_0_, xbuser0_.ldap_server as ldap5_41_0_, xbuser0_.user_name as user6_41_0_, xbuser0_.user_pwd as user7_41_0_ from xb_user xbuser0_ where xbuser0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - resolving associations for [com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - done materializing entity [com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - initializing non-lazy collections
DEBUG - done entity load
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbgroupuse0_.user_id as user2_1_, xbgroupuse0_.group_id as group1_1_, xbgroupuse0_.group_id as group1_65_0_, xbgroupuse0_.user_id as user2_65_0_, xbgroupuse0_.righttype as righttype65_0_ from xb_group_user xbgroupuse0_ where xbgroupuse0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbitems0_.lock_user as lock11_1_, xbitems0_.id as id1_, xbitems0_.id as id13_0_, xbitems0_.deleted as deleted13_0_, xbitems0_.description as descript3_13_0_, xbitems0_.lock_date as lock4_13_0_, xbitems0_.lock_ip as lock5_13_0_, xbitems0_.name as name13_0_, xbitems0_.status as status13_0_, xbitems0_.type as type13_0_, xbitems0_.group_id as group9_13_0_, xbitems0_.project_id as project10_13_0_, xbitems0_.lock_user as lock11_13_0_ from xb_item xbitems0_ where xbitems0_.lock_user=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojectu0_.user_id as user2_1_, xbprojectu0_.project_id as project1_1_, xbprojectu0_.project_id as project1_66_0_, xbprojectu0_.user_id as user2_66_0_, xbprojectu0_.righttype as righttype66_0_ from xb_project_user xbprojectu0_ where xbprojectu0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojects0_.author as author1_, xbprojects0_.id as id1_, xbprojects0_.id as id11_0_, xbprojects0_.createdate as createdate11_0_, xbprojects0_.description as descript3_11_0_, xbprojects0_.name as name11_0_, xbprojects0_.author as author11_0_ from xb_project xbprojects0_ where xbprojects0_.author=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbroledepl0_.user_id as user4_1_, xbroledepl0_.id as id1_, xbroledepl0_.id as id69_0_, xbroledepl0_.deploy_time as deploy2_69_0_, xbroledepl0_.role_id as role3_69_0_, xbroledepl0_.user_id as user4_69_0_, xbroledepl0_.version_id as version5_69_0_ from xb_role_deployed_items xbroledepl0_ where xbroledepl0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbusergrou0_.user_id as user1_1_, xbusergrou0_.user_group_id as user2_1_, xbusergrou1_.id as id25_0_, xbusergrou1_.description as descript2_25_0_, xbusergrou1_.name as name25_0_ from xb_user_memberof xbusergrou0_ left outer join xb_user_group xbusergrou1_ on xbusergrou0_.user_group_id=xbusergrou1_.id where xbusergrou0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - resolving associations for [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6]
DEBUG - done materializing entity [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6]
DEBUG - resolving associations for [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7]
DEBUG - done materializing entity [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7]
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#7]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbgroupuse0_.user_group_id as user2_1_, xbgroupuse0_.group_id as group1_1_, xbgroupuse0_.group_id as group1_58_0_, xbgroupuse0_.user_group_id as user2_58_0_, xbgroupuse0_.righttype as righttype58_0_ from xb_group_user_group xbgroupuse0_ where xbgroupuse0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#7]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#7]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#7]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojectu0_.user_group_id as user2_1_, xbprojectu0_.project_id as project1_1_, xbprojectu0_.project_id as project1_48_0_, xbprojectu0_.user_group_id as user2_48_0_, xbprojectu0_.righttype as righttype48_0_ from xb_project_user_group xbprojectu0_ where xbprojectu0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#7]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#7]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbusers0_.user_group_id as user2_1_, xbusers0_.user_id as user1_1_, xbuser1_.user_id as user1_41_0_, xbuser1_.create_date as create2_41_0_, xbuser1_.global_right as global3_41_0_, xbuser1_.last_login as last4_41_0_, xbuser1_.ldap_server as ldap5_41_0_, xbuser1_.user_name as user6_41_0_, xbuser1_.user_pwd as user7_41_0_ from xb_user_memberof xbusers0_ left outer join xb_user xbuser1_ on xbusers0_.user_id=xbuser1_.user_id where xbusers0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - resolving associations for [com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8]
DEBUG - done materializing entity [com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8]
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbgroupuse0_.user_id as user2_1_, xbgroupuse0_.group_id as group1_1_, xbgroupuse0_.group_id as group1_65_0_, xbgroupuse0_.user_id as user2_65_0_, xbgroupuse0_.righttype as righttype65_0_ from xb_group_user xbgroupuse0_ where xbgroupuse0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbitems0_.lock_user as lock11_1_, xbitems0_.id as id1_, xbitems0_.id as id13_0_, xbitems0_.deleted as deleted13_0_, xbitems0_.description as descript3_13_0_, xbitems0_.lock_date as lock4_13_0_, xbitems0_.lock_ip as lock5_13_0_, xbitems0_.name as name13_0_, xbitems0_.status as status13_0_, xbitems0_.type as type13_0_, xbitems0_.group_id as group9_13_0_, xbitems0_.project_id as project10_13_0_, xbitems0_.lock_user as lock11_13_0_ from xb_item xbitems0_ where xbitems0_.lock_user=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojectu0_.user_id as user2_1_, xbprojectu0_.project_id as project1_1_, xbprojectu0_.project_id as project1_66_0_, xbprojectu0_.user_id as user2_66_0_, xbprojectu0_.righttype as righttype66_0_ from xb_project_user xbprojectu0_ where xbprojectu0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojects0_.author as author1_, xbprojects0_.id as id1_, xbprojects0_.id as id11_0_, xbprojects0_.createdate as createdate11_0_, xbprojects0_.description as descript3_11_0_, xbprojects0_.name as name11_0_, xbprojects0_.author as author11_0_ from xb_project xbprojects0_ where xbprojects0_.author=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbroledepl0_.user_id as user4_1_, xbroledepl0_.id as id1_, xbroledepl0_.id as id69_0_, xbroledepl0_.deploy_time as deploy2_69_0_, xbroledepl0_.role_id as role3_69_0_, xbroledepl0_.user_id as user4_69_0_, xbroledepl0_.version_id as version5_69_0_ from xb_role_deployed_items xbroledepl0_ where xbroledepl0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbusergrou0_.user_id as user1_1_, xbusergrou0_.user_group_id as user2_1_, xbusergrou1_.id as id25_0_, xbusergrou1_.description as descript2_25_0_, xbusergrou1_.name as name25_0_ from xb_user_memberof xbusergrou0_ left outer join xb_user_group xbusergrou1_ on xbusergrou0_.user_group_id=xbusergrou1_.id where xbusergrou0_.user_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#6]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbgroupuse0_.user_group_id as user2_1_, xbgroupuse0_.group_id as group1_1_, xbgroupuse0_.group_id as group1_58_0_, xbgroupuse0_.user_group_id as user2_58_0_, xbgroupuse0_.righttype as righttype58_0_ from xb_group_user_group xbgroupuse0_ where xbgroupuse0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#6]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#6]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#6]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbprojectu0_.user_group_id as user2_1_, xbprojectu0_.project_id as project1_1_, xbprojectu0_.project_id as project1_48_0_, xbprojectu0_.user_group_id as user2_48_0_, xbprojectu0_.righttype as righttype48_0_ from xb_project_user_group xbprojectu0_ where xbprojectu0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#6]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#6]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbusers0_.user_group_id as user2_1_, xbusers0_.user_id as user1_1_, xbuser1_.user_id as user1_41_0_, xbuser1_.create_date as create2_41_0_, xbuser1_.global_right as global3_41_0_, xbuser1_.last_login as last4_41_0_, xbuser1_.ldap_server as ldap5_41_0_, xbuser1_.user_name as user6_41_0_, xbuser1_.user_pwd as user7_41_0_ from xb_user_memberof xbusers0_ left outer join xb_user xbuser1_ on xbusers0_.user_id=xbuser1_.user_id where xbusers0_.user_group_id=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - result row: EntityKey[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9]
DEBUG - found row of collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#8]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbversions0_.author as author1_, xbversions0_.id as id1_, xbversions0_.id as id73_0_, xbversions0_.comment as comment73_0_, xbversions0_.content as content73_0_, xbversions0_.createdate as createdate73_0_, xbversions0_.modification as modifica5_73_0_, xbversions0_.version as version73_0_, xbversions0_.item_id as item7_73_0_, xbversions0_.author as author73_0_ from xb_version xbversions0_ where xbversions0_.author=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#8]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#8]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - loading collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - select xbversions0_.author as author1_, xbversions0_.id as id1_, xbversions0_.id as id73_0_, xbversions0_.comment as comment73_0_, xbversions0_.content as content73_0_, xbversions0_.createdate as createdate73_0_, xbversions0_.modification as modifica5_73_0_, xbversions0_.version as version73_0_, xbversions0_.item_id as item7_73_0_, xbversions0_.author as author73_0_ from xb_version xbversions0_ where xbversions0_.author=?
DEBUG - about to open ResultSet (open ResultSets: 0, globally: 0)
DEBUG - result set contains (possibly empty) collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#9]
DEBUG - about to close ResultSet (open ResultSets: 1, globally: 1)
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - 1 collections were found in result set for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions
DEBUG - collection fully initialized: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#9]
DEBUG - 1 collections initialized for role: com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions
DEBUG - initializing non-lazy collections
DEBUG - done loading collection
DEBUG - commit
DEBUG - processing flush-time cascades
DEBUG - dirty checking collections
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#9]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#6]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#6]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#6]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbGroupUserGroups#7]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbProjectUserGroups#7]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup.xbUsers#7]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbGroupUsers#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbItems#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjectUsers#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbProjects#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbRoleDeployedItemses#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - Collection dereferenced: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbVersions#8]
DEBUG - Flushed: 0 insertions, 0 updates, 4 deletions to 4 objects
DEBUG - Flushed: 0 (re)creations, 0 updates, 20 removals to 20 collections
DEBUG - listing entities:
DEBUG - com.invenso.xb.isp.xbadminserver.database.objects.XbUser{userName=lala, xbProjects=[], xbUserGroups=[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7, com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6], xbItems=[], userId=9, xbRoleDeployedItemses=[], userPwd=64d8be661d8a79416eb6662db51e7118, xbProjectUsers=[], ldapServer=null, xbVersions=[], xbGroupUsers=[], createDate=2008-07-17 17:43:46, globalRight=All, lastLogin=null}
DEBUG - com.invenso.xb.isp.xbadminserver.database.objects.XbUser{userName=OFFICE\brecht, xbProjects=[], xbUserGroups=[com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#7, com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup#6], xbItems=[], userId=8, xbRoleDeployedItemses=[], userPwd=null, xbProjectUsers=[], ldapServer=peserver1, xbVersions=[], xbGroupUsers=[], createDate=2008-07-17 00:00:00, globalRight=All, lastLogin=2008-07-17 17:43:34}
DEBUG - com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup{xbProjectUserGroups=[], xbUsers=[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8, com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9], description=, xbGroupUserGroups=[], name=Administrators, id=7}
DEBUG - com.invenso.xb.isp.xbadminserver.database.objects.XbUserGroup{xbProjectUserGroups=[], xbUsers=[com.invenso.xb.isp.xbadminserver.database.objects.XbUser#8, com.invenso.xb.isp.xbadminserver.database.objects.XbUser#9], description=, xbGroupUserGroups=[], name=Public, id=6}
DEBUG - Deleting collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#9]
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - delete from xb_user_memberof where user_id=?
DEBUG - done deleting collection
DEBUG - Deleting collection: [com.invenso.xb.isp.xbadminserver.database.objects.XbUser.xbUserGroups#8]
DEBUG - reusing prepared statement
DEBUG - delete from xb_user_memberof where user_id=?
DEBUG - done deleting collection
DEBUG - Executing batch size: 2
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - delete from xb_user_group where id=?
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - delete from xb_user where user_id=?
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - delete from xb_user_group where id=?
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG - delete from xb_user where user_id=?
DEBUG - Executing batch size: 1
DEBUG - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG - re-enabling autocommit
DEBUG - committed JDBC Connection
DEBUG - aggressively releasing JDBC connection
DEBUG - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG - trace com.mchange.v2.resourcepool.BasicResourcePool@1f2a9da [managed: 5, unused: 4, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@182b9b5)



Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 3:29 am 
Newbie

Joined: Fri Jun 20, 2008 4:47 am
Posts: 5
Removing the user from the groups before removing the user corrects the problem

Code:
XbUser user = getEntityManager().find(XbUser.class, userID);
         Set<XbUserGroup> userGroups = user.getXbUserGroups();
         for (XbUserGroup group : userGroups) {
            group.getXbUsers().remove(user);
            getEntityManager().persist(group);
         }
         user.getXbUserGroups().clear();
         getEntityManager().remove(user);


However, this is a workaround. The cascade should be from xb_user and xb_user_group to xb_member_of (deleting any occurrences of group_id in xb_member_of when deleting an xb_user_group (or user_id and xb_user), not the other way around (deleting xb_user_groups when a reference to it is deleted from xb_user_memberof...)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 18, 2008 4:27 am 
Newbie

Joined: Fri Jun 20, 2008 4:47 am
Posts: 5
Changing the cascade resolves the problem, unfortunately I still can't find a good explanation about what these cascadetypes mean...

@ManyToMany(cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH }, fetch = FetchType.LAZY)
@JoinTable(name = "xb_user_memberof", joinColumns = { @JoinColumn(name = "user_id", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "user_group_id", nullable = false, updatable = false) })
public Set<XbUserGroup> getXbUserGroups() {
return this.xbUserGroups;
}


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

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.