-->
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: Create Criteria using Query, or use Projections with Query?
PostPosted: Sun Apr 15, 2012 3:08 pm 
Newbie

Joined: Sat Jan 14, 2006 8:03 pm
Posts: 18
I have 2 tables with corresponding classes in a legacy app.

public class SystemEvent {
Long electionId;
}
public class Election {
Long id;
String name;
Date endDate;
}

For some unknown reason there is no foreign key between these two tables. And instead of SystemEvent having an Election Object, it has an electionId.

We have a Statistics page that up until now used Criteria with the SystemEvent Object/table. The problem is now we need to show some statistics using a join on SystemEvent and Election. For example "show me statistics for SystemEvent where election name is xxx". Since there is no field linking these two Objects/tables together, I can't use Criteria, correct?

I thought of using Query instead of Criteria, it's not that big of a change. But we are also doing Projections with the data, and as far as I know you can only use Projections with Criteria, not with Query.

So my questions:

Is there any way to make my query using a Query object and then somehow convert it to a Criteria so I can use Projection? Or,
Is there any way to use Projections with Query objects?

Thanks!


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