1

オブジェクトのリストをクラスにキャストしようとしているのですが、上記のエラーが発生しています (エラーの詳細は以下を参照)。私は周りを見回して提案を試みましたが、何も問題はありません。POJO クラスにブレークポイントを設定しようとしましたが、うまくいきませんでした。Web アプリに関しては、ブレークポイントが機能しないと思います。

取得しているフィールド ( instance_id) は、Oracle 11GR2 DB で数値として宣言されています。

助けていただけますか?

私のネイティブクエリ(hbmファイルで定義されており、return-scalarの有無にかかわらず試しました)

<sql-query name="getEventSessionsForFab1">
    <return-scalar column="instanceId" type="long" />

    <![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 > sysdate and (eventInstance.register_cutoff_date >= sysdate or eventInstance.register_cutoff_date is null) and (lower(event.event_name) like :eventName or event.event_id = 1)]]>
</sql-query>

私のJavaコード

List<EventSession> eventSessionList1 = sessionFactory.getCurrentSession()
                        .getNamedQuery("getEventSessionsForFab1")
                        .setParameter("eventName", "%" + (lovList.size() > 0 ? lovList.get(0).getCode().toLowerCase() : "general") + "%")
                        .setResultTransformer(Transformers.aliasToBean(EventSession.class))
                        .list();

私のJavaクラス(ここにはもっと多くのフィールドがありましたが、テスト用に1つだけ保持しました)

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;
    }

}

Eclipse コンソールに表示される完全なエラー メッセージ

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)
4

1 に答える 1

2

上記のコードを確認しました。return-scalar を long から integer に変更すると、エラーは解消されます。

<sql-query name="getEventSessionsForFab1">
    <return-scalar column="instanceId" type="integer" />
    ...

お役に立てれば。

于 2013-02-22T18:07:19.973 に答える