-->
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.  [ 6 posts ] 
Author Message
 Post subject: Problems retrieving records
PostPosted: Wed Feb 01, 2012 5:25 pm 
Newbie

Joined: Wed Feb 01, 2012 5:12 pm
Posts: 3
Hi,

I have a class (Trade) and a subclass (Operation). They are mapped in the database. So when I do:

trades = session.createQuery("from Trade").list() -> I get an arraylist of trade records and can access the operations for certain trade through trade instance.

However, when I do:

trades = session.createQuery("from Trade as trade inner join trade.operations as operation with to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list(); -> I get an array of objects where each element contains operation and trade instance.

How could I retrieve records as an array of trades (same as first option) with conditions (same as second option)?

Thanks in advance!


Top
 Profile  
 
 Post subject: Re: Problems retrieving records
PostPosted: Fri Feb 03, 2012 2:17 am 
Newbie

Joined: Thu Feb 02, 2012 11:28 pm
Posts: 13
Location: shenzhen china
just have a try like this

trades = session.createQuery("select trade from Trade as trade inner join trade.operations as operation with to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list();


Top
 Profile  
 
 Post subject: Re: Problems retrieving records
PostPosted: Fri Feb 03, 2012 4:14 pm 
Newbie

Joined: Wed Feb 01, 2012 5:12 pm
Posts: 3
Yeah, I tried that and it worked, thanks! However, when I access to the operations list, I see that I get all the operation by any day, so it doesn't satisfy the condition. Any idea?


Top
 Profile  
 
 Post subject: Re: Problems retrieving records
PostPosted: Sun Feb 05, 2012 11:18 pm 
Newbie

Joined: Thu Feb 02, 2012 11:28 pm
Posts: 13
Location: shenzhen china
bribon wrote:
Yeah, I tried that and it worked, thanks! However, when I access to the operations list, I see that I get all the operation by any day, so it doesn't satisfy the condition. Any idea?


哥们,你用的什么数据库?
把with改成where试下
trades = session.createQuery("select trade from Trade as trade inner join trade.operations as operation where to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list();


Top
 Profile  
 
 Post subject: Re: Problems retrieving records
PostPosted: Mon Feb 06, 2012 6:21 pm 
Newbie

Joined: Wed Feb 01, 2012 5:12 pm
Posts: 3
tomyun wrote:
bribon wrote:
Yeah, I tried that and it worked, thanks! However, when I access to the operations list, I see that I get all the operation by any day, so it doesn't satisfy the condition. Any idea?


哥们,你用的什么数据库?
把with改成where试下
trades = session.createQuery("select trade from Trade as trade inner join trade.operations as operation where to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list();


What?


Top
 Profile  
 
 Post subject: Re: Problems retrieving records
PostPosted: Mon Feb 06, 2012 9:46 pm 
Newbie

Joined: Thu Feb 02, 2012 11:28 pm
Posts: 13
Location: shenzhen china
bribon wrote:
tomyun wrote:
bribon wrote:
Yeah, I tried that and it worked, thanks! However, when I access to the operations list, I see that I get all the operation by any day, so it doesn't satisfy the condition. Any idea?


哥们,你用的什么数据库?
把with改成where试下
trades = session.createQuery("select trade from Trade as trade inner join trade.operations as operation where to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list();


What?


Sorry!
I thought you know Chinese.
You can modify "with" to "where",and try it again.

trades = session.createQuery("select trade from Trade as trade inner join trade.operations as operation where to_char(operation.datetime, 'yyyyMMdd') = to_char(sysdate, 'yyyyMMdd') order by operation.datetime").list();

what database do you use?


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