-->
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.  [ 1 post ] 
Author Message
 Post subject: many-to-many set doesn't cascade saves or updates
PostPosted: Tue Dec 13, 2005 10:18 pm 
Newbie

Joined: Mon Sep 26, 2005 2:40 pm
Posts: 17
Location: Seattle
The following mapping doesn't result in save operations cascading to the associated set of Role objects.

To be clear, I'm expecting it to mark the new Role as persisted and assign it an ID even before I call session.close(). I believe this is the expected behavior.

This fails both for already-created objects (save) and pre-existing objects (update). My Dao doesn't distinguish, it calls session.saveOrUpdate(obj).

-Kevin

Hibernate version:
3.1.rc3
Mapping documents:
<hibernate-mapping package="net.speakeasy.domain.account"
schema="moses">

<class name="User" table="userids">
<id name="id" column="userid_id">
<generator class="sequence">
<param name="sequence">userids_gen</param>
</generator>
</id>

<property name="name" column="userid" />
<property name="status" column="status" type="Status" />

<many-to-one name="customer" column="customer_id"
class="net.speakeasy.domain.account.Customer" not-null="true"
cascade="persist,merge,save-update" />

<set name="roles" table="userid_groups" cascade="all">
<key column="userid_id" />
<many-to-many class="net.speakeasy.domain.account.Role"
column="group_id" />
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
testUser = TestData.getUnitTestUser(gateway);
newRole = new Role();
newRole.setDescription("UserDaoTest role");
testUser.addRole(newRole);
userDao.save(testUser);
//this assert fails
assertTrue("Session does not contain new role", getSessionFactory()
.getCurrentSession().contains(newRole));

Name and version of the database you are using:
Oracle 9i


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

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.