-->
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.  [ 3 posts ] 
Author Message
 Post subject: How do you persist set defined with where clause
PostPosted: Mon Aug 15, 2005 9:33 pm 
Newbie

Joined: Mon Aug 15, 2005 9:19 pm
Posts: 8
I have a set defined like so:

Code:
<set name="optionServices" table="target_link" where="from_target_type='s' and to_target_type='s'" lazy="false">
    <key>
        <column name="from_target_id"/>
    </key>
    <element type="java.lang.Long" column="to_target_id" />
</set>


The mapping works fine for reading values but when I try to persist the set I would like from_target_type and to_target_type set to 's'.

Hibernate current generates only:
Code:
insert into target_link (from_target_id, to_target_id) values (?, ?)


How do I get hibernate to insert values for from_target_type and to_target_type as well?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:27 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
perhaps a custom sql

http://www.hibernate.org/hib_docs/v3/reference/en/html/querysql.html#querysql-cud


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 12:54 am 
Newbie

Joined: Mon Aug 15, 2005 9:19 pm
Posts: 8
Thanks anar, that's waht I needed.

Code:
        <set name="optionServices" table="target_link" where="from_target_type='s' and to_target_type='s' and class=2" lazy="false">
            <key>
                <column name="from_target_id"/>
            </key>
            <element type="java.lang.Long" column="to_target_id" />
            <sql-insert>insert into target_link(from_target_id, to_target_id, from_target_type, to_target_type, class) values ( ?, ?, 's', 's', 2)</sql-insert>
            <sql-update>update target_link set to_target_id = ? where from_target_id = ? and from_target_type = 's' to_target_type = 's' class = 2</sql-update>
            <sql-delete>delete from target_link where from_target_id = ? and to_target_id = ? and from_target_type = 's' to_target_type = 's' class = 2</sql-delete>
        </set>


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