-->
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.  [ 4 posts ] 
Author Message
 Post subject: Are discriminators the right approach?
PostPosted: Tue Jun 17, 2008 9:56 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Hi

I'm trying to achieve the following

select acc.*,
(case when balance >= 2*cmp then 'TRUE' else 'FALSE' end)
from account acc
where regulated_by = 'ABC'
and redemption_date is null
and arrears_balance > cmp

The case statement is the bit I'm having problems with. I thought discriminators might be the way to do it (because of their 'formula' value) but now I'm not sure.

Could anyone give me a hint as to what is the best approach please?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 17, 2008 3:26 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
I think this has the Hibernate Criteria API all over it. You can use the Criteria API to create very complicated queries based on your objects, not tables. Remember, Hibernate is all about thinking about your problem domain in the form of your object model, not the underying tables.

Here's a fun little tutorial on the Hibernate3 Criteria API.

http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=09howtousethecriteriaapi

Give it a read, and tell us what your objects are that you are using. Then maybe we can help you do a Criteria query with these objects.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 18, 2008 4:32 am 
Beginner
Beginner

Joined: Thu Apr 12, 2007 10:38 am
Posts: 22
Thanks for the tips Cameron. Just seen your message.

I'll give that tutorial and the Criteria API a whirl - thanks again.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 23, 2008 10:42 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Always happy to help!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.