title: java.lang.IllegalArgumentException: argument type mismatch using setResultTransformer (hibernate)
body: <p>Well I'm trying to cast my list of objects into a class and I'm getting the error above (full error details below). I've looked around and tried suggestions but can't see anything wrong.
  I've tried putting a breakpoint in the POJO class but it didn't work. I guess breakpoints doesn't work when it comes to web apps.</p>
  
  <p>The field I'm retrieving (<code>instance_id</code>) is declared as number in the Oracle 11GR2 DB.</p>
  
  <p>Can you please help?</p>
  
  <p><strong>my native query (defined in my hbm file and I've tried it with and without return-scalar)</strong></p>
  
  <pre><code>&lt;sql-query name="getEventSessionsForFab1"&gt;
      &lt;return-scalar column="instanceId" type="long" /&gt;
  
      &lt;![CDATA[select eventInstance.instance_id as "instanceId" from events event, event_instances eventInstance where event.event_id = eventInstance.event_id and eventInstance.start_date_time &gt; sysdate and (eventInstance.register_cutoff_date &gt;= sysdate or eventInstance.register_cutoff_date is null) and (lower(event.event_name) like :eventName or event.event_id = 1)]]&gt;
  &lt;/sql-query&gt;
  </code></pre>
  
  <p><strong>my java code</strong></p>
  
  <pre><code>List&lt;EventSession&gt; eventSessionList1 = sessionFactory.getCurrentSession()
                          .getNamedQuery("getEventSessionsForFab1")
                          .setParameter("eventName", "%" + (lovList.size() &gt; 0 ? lovList.get(0).getCode().toLowerCase() : "general") + "%")
                          .setResultTransformer(Transformers.aliasToBean(EventSession.class))
                          .list();
  </code></pre>
  
  <p><strong>my java class (there used to be more fields here but I retained only 1 for testing)</strong></p>
  
  <pre><code>package com.myapps.issu.models.database;
  
  public class EventSession {
      private Integer instanceId;
  
      public Integer getInstanceId() {
          return instanceId;
      }
      public void setInstanceId(Integer instanceId) {
          this.instanceId = instanceId;
      }
  
  }
  </code></pre>
  
  <p><strong>full error message as displayed in eclipse console</strong></p>
  
  <pre><code>Feb 14, 2013 5:01:06 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet [spring] in context with path [/issu] threw exception [Request processing failed; nested exception is org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of com.myapps.issu.models.database.EventSession.instanceId] with root cause
  java.lang.IllegalArgumentException: argument type mismatch
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:65)
      at org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:95)
      at org.hibernate.hql.internal.HolderInstantiator.instantiate(HolderInstantiator.java:95)
      at org.hibernate.loader.custom.CustomLoader.getResultList(CustomLoader.java:395)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2227)
      at org.hibernate.loader.Loader.list(Loader.java:2222)
      at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:331)
      at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1783)
      at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:231)
      at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:156)
      at com.myapps.issu.dao.IssuDaoImpl.getEventSessionsForFab(IssuDaoImpl.java:122)
      at com.myapps.issu.services.IssuServiceImpl.getEventSessionsForFab(IssuServiceImpl.java:125)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
      at $Proxy13.getEventSessionsForFab(Unknown Source)
      at com.myapps.issu.controllers.IssuController.getEventSessions(IssuController.java:120)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:100)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:604)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:565)
      at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
      at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
      at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
      at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
      at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
      at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
      at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      at java.lang.Thread.run(Thread.java:680)
  </code></pre>