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: List using Calendar
PostPosted: Wed Nov 05, 2003 12:23 pm 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi...

I

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 4:11 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
First, you are just building invalid query (because it will contain WHERE clause three times).
Second, you should never concatenate _parameters_ to query string

Public List listUsers(Calendar dtInitial, Calendar dtFinal)
{
String query = "from User u where u.dtInclusion >= :dtInitial and u.dtInclusion >= :dtFinal";
query.setCalendar("dtInitial", dtInitial);
query.setCalendar("dtFinal", dtFinal);

sess.createQuery(query);
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 4:12 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Ooops

Code:
Public List listUsers(Calendar dtInitial, Calendar dtFinal)
{
    String queryText = "from User u where u.dtInclusion >= :dtInitial and u.dtInclusion >= :dtFinal";
    Query query = sess.createQuery(queryText);
    query.setCalendar("dtInitial", dtInitial);
    query.setCalendar("dtFinal", dtFinal);

    return query.list()
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 05, 2003 4:15 pm 
Expert
Expert

Joined: Tue Sep 16, 2003 4:06 pm
Posts: 318
Location: St. Petersburg, Russia
Although I think dtFinal comparisong operator should be <= not >= ...


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.