-->
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.  [ 4 posts ] 
Author Message
 Post subject: Mapping to non unique id columns
PostPosted: Tue Sep 14, 2004 3:08 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
I'd like to map my id to a column which is not unique. After having a look at the code of the load method of the EntityLoader.java I think Hibernate throws an exception if it detects, that there is more than one row returned for a query by id.
Is there a way to make Hibernate generating a select distinct, or just take the first row of the result set and ignore the others?

I do understand, that i could create a view, doing the distinct stuff, unfortunately, I'm not allowed to change the DB schema.

TIA
Ernst



Hibernate version:
2.1.6

Name and version of the database you are using:
Oracle 8/9, Sybase


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 3:19 pm 
Beginner
Beginner

Joined: Mon May 03, 2004 1:25 pm
Posts: 31
You can use an HQL statement SELECT DISTINCT <object> from <object>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 3:21 pm 
Beginner
Beginner

Joined: Mon May 03, 2004 1:25 pm
Posts: 31
also in Hibernate3, you have the ability define <load> tags which may give you what you need.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 14, 2004 3:29 pm 
Expert
Expert

Joined: Thu Jan 29, 2004 2:31 am
Posts: 362
Location: Switzerland, Bern
Hi

Thanks for your help duggant. AFAIK Hibernate 3 will solve the problem, but I think it's not a good idea to use it in production in the next few weeks.

My scenario is, that the class with the non unique id is referenced by an other class and I'd like to make Hibernate resolving this reference without writing HQL.
If it would be only one reference, yes why not doing it via HQL and wait for Hibernate 3, unfortunately I've dozens of them.

TIA
Ernst


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