• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibenate select problem

 
sameer sood
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends

This is the code i am using

Query q = session.createQuery("from ApplicationHours a where a.username = :username " + " and Month(a.claimMonth) = :month and year(a.claimMonth) = :year");

q.setString("username", applicationHours.getUsername());
q.setInteger("month", 5);
q.setInteger("year", 2008);

if( q.list().isEmpty())
return q.list();
else
return null;

Despite values being there i get null as output ??

Database is right as it is working for other tables and insert is working fine, ApplicationHours is a class defined containing all fields mentioned
Please help , am i using month year in a wrong way??
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see the problem right off the bat, but if all else fails, why not try breaking the query down a little bit.

Start off with:



and see if it works. It should. Then:



and see if it works. Then:



If the simple query does work, then you know the whole system integrates, and your job it to now isolate the part of the query that is failing. If the first, simple query does not work, then you know you have a more fundamental problem.

Let us know how things turn out!

-Cameron McKenzie
 
sameer sood
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a logical mistake no technical problem there
just putting ! in the condition solves it
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic