-->
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: Join Table w/ Many-To-Many - Can't Insert bc of Xtra Cols
PostPosted: Fri Jan 09, 2009 2:21 pm 
Newbie

Joined: Fri Jan 09, 2009 2:12 pm
Posts: 2
Hi, I have a table schema like:

Role
-----
Id
Name
Create_TS
UpdatedBy

Resource
-----
Id
Name
Create_TS
UpdatedBy

ResourceRole
----
RoleId (fk)
ResourceId (fk)
Create_TS (non-nullable)
Update_TS (non-nullable)
UpdatedBy (non-nullable)

My mappings are ok (only have Role.hbm.xml, and Resource.hbm.xml), but when I get to the point of something like this:

resource.getRoles().addRole(role)
_dao.save(resource);

I get a failure, saying it couldn't insert into the ResourceRole table because there was a non-nullable column (ie. Create_TS, Update_TS, and UpdatedBy) that it's trying to insert as Null. Any ideas on how I can intercept these inserts/updates and populate these values?

<set name="roles" table="RESOURCE_ROLE" cascade="save-update">
<key>
<column name="ResourceId"/>
</key>
<many-to-many class="com.bcato.security.model.SecurityRole">
<column name="RoleId"/>
</many-to-many>
</set>

Thanks,

-Shem


Last edited by shemazar2 on Fri Jan 09, 2009 3:00 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Some additional info...
PostPosted: Fri Jan 09, 2009 2:57 pm 
Newbie

Joined: Fri Jan 09, 2009 2:12 pm
Posts: 2
I should state that I've tried an interceptor...

The statement it generates is like the following:

insert into ResourceRole (ResourceId, RoleId) values (?, ?)

It doesn't know anything about the other columns. Nor does the "onSave" of the interceptor called for the join table (since there's no bean reference to it). I think I could accomplish what I want if I could reference a class for the join table.


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.