-->
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: adding a constant column value when inserting?
PostPosted: Fri May 20, 2005 6:59 am 
Newbie

Joined: Thu May 12, 2005 7:42 am
Posts: 3
I'm evaluating the possibility of using hibernate with our legacy database schema and when writing some test code I stumbled into this:

Thre is an ADDRESS table in the database holding different types of addresses (email and postal). Each type is identified by a different ADDRESS_TYPE_ID. Now I want to map a set of Address objects to a Person corresponding to all the rows in ADDRESS with matching PERSON_ID and ADDRESS_TYPE_ID = 1.

For reading it works great with <set ... where="ADDRESS_TYPE_ID = 1">, but inserting is another story. How do I tell hibernate to set ADDRESS_TYPE_ID to 1 for all persisted Address instances?

The idea I have come up with is adding a custom UserType for some simple value in the Address mapping that also inserts a value for ADDRESS_TYPE_ID, but that solution seems kind of ugly.


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.