-->
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: Criteria Query, using 2 example queries, howto?
PostPosted: Wed Jan 18, 2006 10:04 am 
Beginner
Beginner

Joined: Tue Jan 11, 2005 5:50 am
Posts: 43
Location: Zurich (Suisse)
Hibernate version:
3.1

Full stack trace of any exception that occurs:
ClassCastException
Name and version of the database you are using:
Oracle 10g


Hi there, I am having a hard time with the following problem, if anyone could help me, I'd be quite happy.

I have the following relations:

A Matter has o..n roles, a role has 0...n parties.

So in code it is something like Matter.getRoles(), Party.getRoles().

What I was trying to achieve is that I use an example query for Party or Matter - the user sets the name of the party or the subject of the matter and both objects are used for an example query.

Pseudo Code:
Create a criteria on parties, use the example party object to select the right parties, from each party get the roles, from the roles select each role that has a matter that satisfies the matter example query object.

This is what I got (one of the many tries), this will give me a class cast exception for matter :(


Code:
public List lookupCandidates(Matter matter, Party party) throws PersistencyException {
        /**/       
        Example example = Example.create(party);
       
        Criteria criterias = getCurrentSession().createCriteria(Party.class);
        criterias.add(example);       
        Criteria roleCriteria = criterias.createCriteria("roles");   
        roleCriteria.setFetchMode("roles", FetchMode.JOIN);
        roleCriteria.add(Example.create(matter));       
        List list = criterias.list();
        return list;


Any input greatly appreciated.[/code]


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.