Hello Everyone,
Is there any restrictions in JPQL for date equality comparision?
My requirement is to get all the student's information based on the admission date. viz. If admissionDate is date-16.02.2010 time-15:03:08, then it should give me all the student's information who has admitted on date-"16.02.2010" time-"15:03:08"
In my orm.xml mapping file, i've the following JPQL query defined: -----------clip--------- <orm:named-query name="valuesByKeys"> <orm:query>SELECT NEW studentValueDTO(x) FROM Student x WHERE x.admissionDate = :admissionDate</orm:query> </orm:named-query> -----------clap---------
"Student" is an ejb3.0 entity class which has a "admissionDate" field of type java.util.Date. -----------clip--------- @Column(name = "ADMISSION_DATE") @Temporal(TemporalType.DATE) private java.util.Date admissionDate; -----------clap---------
"StudentValueDTO" is a data tranferable object having just getters & setters methods.
I've following ejb 3.0 stateless session bean, which uses the orm.xml mapping file for making DB query: ----------------clip-------------- @PersistenceContext private javax.persistence.EntityManager manager;
public List<StudentValueDTO> getStudentInfo (java.util.Date admissionDate){
javax.persistence.Query query = manager.createNamedQuery("valuesByKeys"); query.setParameter("admissionDate", admissionDate); List<StudentValueDTO> result=(List<StudentValueDTO)query.getResultList(); manager.clear(); return result; } ----------------clap--------------
I've written an ejb client (Out of container) to invoke the above stateless bean: ----------clip---------- java.util.Calendar cal = Calendar.getInstance(); cal.set(2010,01,16,15,03,8);
List<StudentValueDTO> studentList = remoteObject.getStudentInfo(cal.getTime()); ----------clap----------
But when i print the contents of studentList, its always empty. Also, i confirmed with the logs of hibernate, the query seems to be formed properly & binding too. But there are no result sets returned for this query. I checked in my oracle DB, there are lots of data which matches this criteria i.e. having admissionDate as provided.
Require your kind help in this regard. Thanks in advance.
_Sanjit
|