-->
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.  [ 3 posts ] 
Author Message
 Post subject: Operations on columns using Criteria queries
PostPosted: Wed Mar 28, 2007 4:02 am 
Newbie

Joined: Mon Jun 27, 2005 7:43 am
Posts: 13
Location: Barcelona, Spain
Hibernate version: 3.2.2

Name and version of the database you are using: Oracle 10g

Hi all,

Just wondering if this is feasible using Criteria queries, and how...

Let's say I want to fetch the rows of a table consisting of 2 DATE columns (DATE1 and DATE2) in which DATE1 and DATE2 are from the same month and year.

The only solution I found so far was to fetch all the rows, and then iterate and check for each row whether DATE1 and DATE2 were matching my restriction. Obviously, this way is far from being the best performance-wise.

Does anyone know any solution that would avoid fetching all the rows?

Thanks in advance,
alexis


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 5:49 am 
Regular
Regular

Joined: Mon Jun 12, 2006 5:33 am
Posts: 63
Hi Sixel,
what kind of restriction do you want?
You can also use HQL (closer to SQL if you're not comfortable with Criteria) to make queries.

Chucky - Don't forget to rate if this helps


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 28, 2007 5:56 am 
Newbie

Joined: Mon Jun 27, 2005 7:43 am
Posts: 13
Location: Barcelona, Spain
chucky wrote:
Hi Sixel,
what kind of restriction do you want?

As I said, I need to fetch only the rows with DATE1 and DATE2 within the same month

chucky wrote:
You can also use HQL (closer to SQL if you're not comfortable with Criteria) to make queries.

I'm actually quite comfortable with Criteria queries, and the above problem is just a stripped down example from a much more complex query I use.
HQL is not a solution for me in this case, I have to stick to using Criteria.

Thanks for the help,
alexis


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