Solved

HQL query needed

Posted on 2011-09-22
2
389 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
topping2 challenge 13 89
Spring Framework HTTPSession management 1 33
replace a word with other 1 43
even odd program using while loop 3 40
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

815 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now