-->
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.  [ 2 posts ] 
Author Message
 Post subject: Is onSave (Interceptor callback) called for cascaded objs?
PostPosted: Wed Sep 03, 2003 3:57 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
It doesn't look like onSave gets called for userxref below. Note that userxref is a composite-element used for extra cols in a many-to-many. Should onSave get called? Or must I loop thru the collection (roles) myself, knowing that if this user is new then all the UserRole's are by default new?

Jeff

Code:
roleA = new Role( new Long (1), "Role A");
roleB = new Role( new Long (2), "Role B");
user = new AppUser( new Long(100), "Jeff Boring ");
user.setEmailAddr( "jeff.boring@siemens.com");
user.setUserId( "jwboring");
user.setPassword( "password");
         
userxref = new UserRole("Serving as role A on project", roleA, user );
userxref.setUserId("JWB");
userxref.setTransCode("add");
      
user.getRoles().add( userxref );
sess.save( roleA );
sess.save( roleB );
sess.save( user );


Mapping file:
Code:
<class name="AppUser" table="AppUser" >
    <id
        name="userskey"
        type="java.lang.Long"
        unsaved-value="any"
    >
        <generator class="assigned" />
    </id>
    <property name="name" type="java.lang.String" length="20" />
    <property name="emailAddr" type="java.lang.String" length="50" />
    <property name="userId" type="java.lang.String" length="20" />
    <property name="password" type="java.lang.String" length="20" />

    <!-- bi-directional many-to-many association to Role -->
    <set name="roles" lazy="false" table="UserRole" cascade="all" >
        <key column="userskey" />
        <composite-element class="UserRole" >
           <property  not-null="true" name="noteComment" type="java.lang.String" />
           <property  not-null="false" name="userId" type="java.lang.String" />
           <property  not-null="false" name="transCode" type="java.lang.String" />
           <many-to-one name="role" class="Role">
              <column name="roleskey" />
           </many-to-one>
        </composite-element>
    </set>

</class>
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 03, 2003 7:09 pm 
Regular
Regular

Joined: Tue Aug 26, 2003 7:53 pm
Posts: 66
Location: Lakeland, Florida USA
UserRole is not an entity / persisent obj so perhaps it doesn't make sense for the onSave call. If this is the case then the value of the composite-element as used here (over just 2 1-to-many mappings) is diminished. What's wrong with 2 1-to-manys, user to userRole and role to userRole? Anything?

Jeff


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.