Solved

HQL query needed

Posted on 2011-09-22
2
393 Views
Last Modified: 2012-06-21
Hi - I need a HQL query for the following

select * from table where name in('name1','name2') and created_date >= to_date('01/01/2011','MM/dd/yyyy') and updated_date <= to_date('09/21/2011','MM/dd/yyyy')

Thanks
0
Comment
Question by:abuyusuf35
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 47

Expert Comment

by:for_yan
ID: 36584547


I think is should be like that:

Query query = session.createQuery("from Table as table where table.name in ('name1','name2') and table.created_date >= :startDate and table.updated_date <= :endDate");
query.setDate("startDate", Date.valueOf("2011-01-01");
query.setDate("endDate", Date.valueOf("2011-09-21");

Open in new window


0
 
LVL 21

Accepted Solution

by:
Amitkumar Panchal earned 500 total points
ID: 36708427
Try the following


List variableList = new ArrayList();
variableList.add("name1");
variableList.add("name2");
Query query = session.createQuery("from Table as table where table.name in (:nameList) and table.created_date >= :startDate and table.updated_date <= :endDate");
query.setDate("nameList", variableList);
query.setDate("startDate", Date.valueOf("2011-01-01"));
query.setDate("endDate", Date.valueOf("2011-09-21")); 

Open in new window

0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question