Reputation: 18110
I have a login controller that use the hibernate uniqueResult method. Everything works fine when i test it in eclipse's tomcat server. But when i deploy my webapps to tomcat server (on the same machine) it fails: it always returns null even i use the correct credential.
Here is my hibernate code:
session.createCriteria(User.class)
.add(Restrictions.eq(User.USERNAME_FIELD, userName))
.add(Restrictions.eq(User.PASSWORD_FIELD, password)).uniqueResult();
Thank you!
Upvotes: 4
Views: 10286
Reputation: 45735
There is not enough information, try to trace the SQL that is being generated:
Set in log4j.properties
log4j.logger.org.hibernate.SQL=TRACE
log4j.logger.org.hibernate.type=TRACE
Or set these Hibernate properties
hibernate.show_sql=true
hibernate.format_sql=true
Then try to run these queries, with the passed parameters that return null directly in the database.
Upvotes: 1
Reputation: 3013
Maybe you should try to see the actual hibernate query and parameters using the logger. The two loggers you should make to "debug" are:
org.hibernate.SQL
org.hibernate.type
Put both on TRACE
or ALL
and check the result on logging. For more information about the logger see the hibernate documentation.
The most common case would be log4j. AFAIK, hibernate.show_sql
is deprecated.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="Stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<logger name="org.hibernate.SQL">
<level value="TRACE"/>
</logger>
<logger name="org.hibernate.type">
<level value="TRACE"/>
</logger>
<root>
<level value="INFO"/>
<appender-ref ref="Stdout"/>
</root>
</log4j:configuration>
Upvotes: 5