-->
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: QBE uniqueResult()
PostPosted: Thu Nov 18, 2004 8:54 am 
Newbie

Joined: Thu Sep 02, 2004 8:33 am
Posts: 6
I have a little question!

I'am trying to do a query by example on a primary key.
I know that of you put it in a List he is ignoring the primary key.
But i now just want one result.

Artikel result;

Example exampleObject = Example.create(artikel).excludeZeroes(); Criteria criteria = session.createCriteria(Artikel.class);
result = (Artikel) criteria.add(exampleObject).uniqueResult();
return result;

if i search for another variable which is not the primary key it is working fine. Is it possible to do a QBE on a primary key as i am doing above.

for primary key:

13:54:08,031 DEBUG SQL: select this.ArtikelNr as ArtikelNr0_, this.Brutoprijs as Brutoprijs0_, this.Omschrijving as Omschrij3_0_, this.Voorraad as Voorraad0_, this.Kortingsgroep as Kortings5_0_, this.ArtikelNrLev as ArtikelN6_0_, this.LeverancierNr as Leveranc7_0_ from artikel this where (1=1)
for normal variable:

13:46:37,500 DEBUG SQL: select this.ArtikelNr as ArtikelNr0_, this.Brutoprijs as Brutoprijs0_, this.Omschrijving as Omschrij3_0_, this.Voorraad as Voorraad0_, this.Kortingsgroep as Kortings5_0_, this.ArtikelNrLev as ArtikelN6_0_, this.LeverancierNr as Leveranc7_0_ from artikel this where (this.ArtikelNrLev=?)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 18, 2004 8:58 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
No, an Example query ignores the database identifier, as documented. Use lookup by identifer, ie. load() or get().

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.