-->
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.  [ 2 posts ] 
Author Message
 Post subject: Conditionall Mapping
PostPosted: Mon Mar 13, 2006 7:42 am 
Newbie

Joined: Fri Mar 03, 2006 1:28 pm
Posts: 9
Hi
I've read some posts about this but still got no idea how to do this.

I have a proprety in a class that I wish to map to two different columns on a table: the class attribute should assume the value from the one column that is not null (those two columns are never either both null nor not null).

I hope i've explained myself correctly, and now i'm hoping for help on this.

Thank you very much for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 6:35 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
If the columns are read only, then you want something like
Code:
<property name="prop" formula="(case when col1 is null then col2 else col1 end)"/>
Or "isnull(col1, col2)" if your DB has the isnull function.

If the columns are read-write, then map them separately and do the logic in java.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.