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: Application-specific NULL
PostPosted: Tue Jan 31, 2012 11:39 am 
Newbie

Joined: Tue Jan 31, 2012 11:26 am
Posts: 2
Hello,

We have a table where on one column (some id of integer type) we have one-to-one relations.
For some records, this column is unassigned, and we store there -1.
-1 is our application-level NULL that prevents use of outer join.

Where is the problem?
In certain cases, Hibernate executes a query on the source table with ‘-1’ and gets more than one record..which is a violation since of the rule due to 1:1 relation and that column must be unique..

How do we tell Hibernate that ‘-1’ value shall act as NULL and it can be many-to-one for this case?
e.g. for all IDs > 1 it is one:one, and for -1 it is many:one?


Is there ‘by-the-book’ solution?

-- Michael


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.