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.
|