Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HQL query needed

Posted on 2011-09-22
2
Medium Priority
?
398 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 2000 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

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

886 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