Java 1.5
Tomcat 5.5.9
libs from the Hibernate Source Zip of November 17, 2005
I have code which is calling:
Code:
System.out.println("coming in qry");
strSQL = " SELECT count(T.ticket_id) as Hits, datepart(mm,T.created) as Mn, datepart(yyyy,T.created) as Yr ";
strSQL += " FROM Tickets T ";
strSQL += " WHERE DateDiff(mm,T.created,getdate()) >= 0 AND DateDiff(mm,T.created,getdate()) < 12 ";
strSQL += " group by datepart(mm,T.created), datepart(yyyy,T.created) ";
strSQL += " order by Yr, Mn ";
System.out.println("coming before session: " + strSQL);
SQLQuery sql = getSession().createSQLQuery(strSQL);
// help to understand the return types
sql = sql.addScalar("Hits", Hibernate.INTEGER);
sql = sql.addScalar("Mn",Hibernate.INTEGER);
sql = sql.addScalar("Yr",Hibernate.INTEGER);
System.out.println("-->" + sql.getQueryString());
lst = sql.list();
So basically, I'm calling a custom SQL query from inside hibernate's session.
The error thrown was:
Code:
Exception caught: java.lang.Boolean
java.lang.ClassCastException: java.lang.Boolean
at org.hibernate.type.StringType.toString(StringType.java:44)
at org.hibernate.type.NullableType.toLoggableString(NullableType.java:169)
at org.hibernate.pretty.Printer.toString(Printer.java:53)
at org.hibernate.pretty.Printer.toString(Printer.java:90)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:97)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:881)
at org.hibernate.impl.AbstractSessionImpl.getNativeSQLQueryPlan(AbstractSessionImpl.java:115)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:121)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:168)
at com.duanemorris.bo.helptraxdeuce.dao.TicketsDAO.getTicketGraph(TicketsDAO.java:269)
at com.duanemorris.bo.helptraxdeuce.dao.TicketsDAO.getTicketGraphCount(TicketsDAO.java:288)
at com.duanemorris.ui.webapps.discovery.helptrax.Home.handleRequest(Home.java:124)
at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doRequest(VelocityViewServlet.java:407)
at org.apache.velocity.tools.view.servlet.VelocityViewServlet.doGet(VelocityViewServlet.java:373)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:118)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
I tracked the error down to this segment of code inside Hibernate by using the Stack Trace [AbstractFlushingEventListener.java:97]:
Code:
//some statistics
if ( log.isDebugEnabled() ) {
log.debug( "Flushed: " +
session.getActionQueue().numberOfInsertions() + " insertions, " +
session.getActionQueue().numberOfUpdates() + " updates, " +
session.getActionQueue().numberOfDeletions() + " deletions to " +
persistenceContext.getEntityEntries().size() + " objects"
);
log.debug( "Flushed: " +
session.getActionQueue().numberOfCollectionCreations() + " (re)creations, " +
session.getActionQueue().numberOfCollectionUpdates() + " updates, " +
session.getActionQueue().numberOfCollectionRemovals() + " removals to " +
persistenceContext.getCollectionEntries().size() + " collections"
);
new Printer( session.getFactory() ).toString(
persistenceContext.getEntitiesByKey().values().iterator(),
session.getEntityMode()
);
}
So it seems that a boolean is being passed as a parameter when a string is to be expected.
To fix the problem, I changed our Log4J properties from DEBUG to a higher level.
If this is helpful to the developers or a fix has been provided already, I'd appreciate any feedback to this topic.
Thanks.