-->
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: Help with Criteria and Query by Example
PostPosted: Fri Sep 24, 2004 12:09 pm 
Beginner
Beginner

Joined: Tue Sep 21, 2004 1:49 pm
Posts: 33
Location: Bogota, Colombia
Hibernate version:2.1.6

Hi, I'm trying to do a combination of Query by Example and some Expressions..

I have 4 classes:

- Company (has a set of "Agencies")
- Agency (has a component "Address")
- Address (a component having a "Zipcode" object among others)
- Zipcode

What I need to do is, to recieve a Company object to use as example and to receive the Zipcode object, to know what company has agencies in that area.

As you can see, the navigation here is company.agencies.address.zipcode.

Looking through the hibernate_docs I could find how to get there using the Criteria API.

I have something like this:

Criteria criteria = sess.createCriteria(Company.class);
criteria.add( Example.create(company) );
criteria.createCriteria("agencies.Address").add(Expression.eq("zipcode", zipcode));

Any help would be much appreciated!


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.