-->
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: Compsite element with many-to-one, delete problems
PostPosted: Mon Apr 18, 2005 2:34 pm 
Beginner
Beginner

Joined: Thu Feb 17, 2005 4:20 pm
Posts: 29
Hibernate version: H3

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

I have a many to many relationship between users and roles that I am mapping as follows:
Code:
<set name="userRoles" table="USER_ROLE" cascade="all-delete-orphan">
    <key column="USER_ID"/>
    <composite-element class="com.biperf.core.domain.user.UserRole">
        <parent name="user" />
        <many-to-one name="role" class="com.biperf.core.domain.user.Role" column="ROLE_ID" />
        <property name="auditInfo" type="com.biperf.core.utils.hibernate.AuditInfoType">
            <column name="DATE_MODIFIED"/>
            <column name="DATE_CREATED"/>
            <column name="MODIFIED_BY"/>
            <column name="CREATED_BY"/>
        </property>
    </composite-element>
</set>


Now when I delete a userRole from the userRoles set, Hibernate generates the following sql statment:
Code:
delete from USER_ROLE where USER_ID=? and ROLE_ID=? and DATE_MODIFIED=? and DATE_CREATED=? and MODIFIED_BY=? and CREATED_BY=?


The trouble is that modifiedBy and dateModifed can be null, and when they are the above sql statement fails.

How do I get Hibernate to generate the delete statement with only USER_ID and ROLE_ID?

Here is what I want...
Code:
delete from USER_ROLE where USER_ID=? and ROLE_ID=?


I have the issue with update statments...[/code]


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.