-->
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: Need help with Composite key and query by example
PostPosted: Tue Oct 25, 2005 7:21 pm 
Newbie

Joined: Sun May 22, 2005 7:29 am
Posts: 6
Hi

I'm trying to use query by example on an entity that contains a composite key. If I setup the Key object with the values to be used in the SELECT and then add it to the Entity, NHibernate ignores the values (and attempts to retrieve everything in the table).

I can't use the CreateCriteria.Add( ) method as you do for associations because the key isn't an association.

Can anyone provide an example of how to achieve this?

The code currently looks something like this:

Code:
   CountryStateZipLocality example = new CountryStateZipLocality();
   example.ID = new CountryStateZipLocalityPK();
   example.ID.ZipCode = "2600";

   criteria.Add( Example.Create( example ) );

   // The following line causes an error as "ID" isn't an association path
   criteria.CreateCriteria( "ID" ).Add( Example.Create( example.ID ) );

   IList resultsList = criteria.List();


Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 9:09 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
Hi merge_alistair.

Are you using query by example? If true, could you help me?

Please, take a look at this post: http://forum.hibernate.org/viewtopic.php?t=954547

Thanks! :~)


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.