-->
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 API
PostPosted: Tue May 20, 2008 2:29 pm 
Newbie

Joined: Thu Nov 01, 2007 11:14 am
Posts: 5
Location: Austin, TX
I'm trying to write a general-purpose search function for my app and am looking into the Criteria API for doing so. Its ability to dynamically generate searches is rather powerful and attractive.

However, I've hit a few snags. It's easy enough to say do simple equality checks, gt, lt, and "in" predicates, but past that seems a bit arcane.

I have two cases I need to figure out:

1. I have a Person object that has a set of email addresses. To complicate matters, this isn't actually a set, but a java Map between address types and addresses (such as "home", "other", "work" email addresses). These are mapped like so:

Code:
<map name="emailAddressesInternal" table="Person_EmailAddresses">
    <key column="person_id" not-null="true" />
    <map-key-many-to-many column="addresstype_id" class="esta.dataobjects.AddressType" />
    <element column="email_address" type="string" />
</map>


How can I say "find me all people with email address bob@example.com"?

2. If there is a one-to-many relationship between an object A (one) and an object B (many), how do I make a criteria search for all B's that are related to A?

Basically I want to know how to do object-equality criteria (based on id), and how to do searching within a set or map.

Thanks in advance.


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.