-->
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: Dynamic insertion on join table mappings
PostPosted: Tue Jul 25, 2006 12:33 am 
Newbie

Joined: Tue Jul 25, 2006 12:15 am
Posts: 1
Is there a way to insert a row in join tables only if all the properties in the table is not-null. I'm already using optional="true" in the join for the tables but Hibernate seems to be inserting even when a property for the join is null.

Mapping file
--------------

<class name="com.app.user" table="user">

<id name="id" column="user_id">
<generator class="sequence"><param name="sequence">seq_user_id_seq</param></generator>
</id>

<property name="login" column="login" type="string" not-null="true" unique="true"/>
<property name="password" column="password" type="string" not-null="true"/>
<property name="firstName" column="first_name" type="string"/>

<join table="cs_user" optional="true">
<key column="user_id"/>
<property name="csCreatedBy" column="created_by" type="long" not-null="true"/>
<property name="csCreatedOn" column="created_on" type="timestamp"/>
</join>

<join table="ut_user" optional="true">
<key column="user_id"/>
<property name="utCreatedBy" column="created_by" type="long" not-null="true"/>
<property name="utCreatedOn" column="created_on" type="timestamp"/>
</join>

</class>

What I would like to achieve is don't insert a row for the join if a property for example utCreatedOn is null. It seems that the 'optional' attribute is not doing that although according to the documentation it should be. Thanks.


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.