DB2에 대해 최대 절전 모드를 사용하고 있습니다. 열거 형 값 목록 인 매개 변수로 NameQuery를 만들면 getResultList()가 잘못된 변환 예외를 throw합니다.최대 절전 모드에서 열거 형 목록을 namedQuery.setParameter()에 전달한 후 잘못된 변환 예외가 발생했습니다.
@NamedQuery(
name="Deliverable.deliverableFiles",
query="Select distinct f " +
"from Deliverable d JOIN d.deliverableFiles f JOIN f.architectures a " +
"where d.visibility in (:visibilities) and a.architecture in (:architectures) " +
"and d.hidden = false and releaseType in (:releaseTypes) "
)
Java 메소드 : 메소드가 호출되는
public static List<DeliverableFile> getDeliverableFiles(EntityManager em, ArrayList<DeliverableVisibility> visibilities,
ArrayList<DeliverableArchitectureType> architectures,
ArrayList<DeliverableReleaseType> releaseTypes, int limit) {
Query deliverableFiles = em.createNamedQuery("Deliverable.deliverableFiles");
deliverableFiles.setFlushMode(FlushModeType.COMMIT);
deliverableFiles.setParameter("visibilities", visibilities);
deliverableFiles.setParameter("architectures", architectures);
deliverableFiles.setParameter("releaseTypes", releaseTypes);
List<DeliverableFile> files;
try {
files = deliverableFiles.getResultList(); // exceptions is thrown here
} // end try
catch (NoResultException nre) {
files = null;
} // end catch
return files;
} // end getDeliveries()
예외 :
ERROR: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.GenericJDBCException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1377)
at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1300)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:266)
at **hidden**.jpa.main.Deliverable.getDeliverableFiles(Deliverable.java:68)
at **hidden**.dbtestbed.DBTestbed.main(DBTestbed.java:165)
Caused by: org.hibernate.exception.GenericJDBCException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:129)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy40.setBytes(Unknown Source)
at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$1.doBind(VarbinaryTypeDescriptor.java:57)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:305)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:300)
at org.hibernate.param.NamedParameterSpecification.bind(NamedParameterSpecification.java:66)
at org.hibernate.loader.hql.QueryLoader.bindParameterValues(QueryLoader.java:588)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1736)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1697)
at org.hibernate.loader.Loader.doQuery(Loader.java:832)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
at org.hibernate.loader.Loader.doList(Loader.java:2382)
at org.hibernate.loader.Loader.doList(Loader.java:2368)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
at org.hibernate.loader.Loader.list(Loader.java:2193)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1244)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:257)
... 2 more
Caused by: com.ibm.db2.jcc.a.SqlException: [jcc][1083][10406][4.2.73] Illegal conversion: can not convert from "byte[]" to "java.lang.String" ERRORCODE=-4474, SQLSTATE=null
at com.ibm.db2.jcc.a.cd.a(cd.java:650)
at com.ibm.db2.jcc.a.cd.a(cd.java:60)
at com.ibm.db2.jcc.a.cd.a(cd.java:94)
at com.ibm.db2.jcc.a.gc.a(gc.java:677)
at com.ibm.db2.jcc.a.vl.a(vl.java:1207)
at com.ibm.db2.jcc.a.vl.setBytes(vl.java:1174)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setBytes(NewProxyPreparedStatement.java:235)
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.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
... 24 more
어떤 힌트 나 단서 또는 생각이 크게 감사하고 있습니다.
빠른 응답을 보내 주셔서 감사합니다. 올바른 열 형식으로 변환하면 어떤 의미인지 이해할 수 없습니다. DB2에서 이러한 열은 varchar입니다. JPQL은 그것들을 상응하는 Enum으로보고 있으므로 ArrayList을 전달할 수 없습니다. 그래서, 열거 형 값을 명명 된 쿼리 매개 변수에 대한 컬렉션으로 어떻게 전달합니까? 감사. –
Hank
그래서 배열의 위치가 'String1', 'String2', 'String3'으로 변환되어야합니다. –
하드 코딩 됨 : deliverableFiles.setParameter ("visibilities", "INTERNAL '"); JPQL은 그것을 좋아하지 않습니다. 열거 형을 setParameter에 전달하려고합니다. java.lang.IllegalArgumentException : 매개 변수 값 [ 'INTERNAL']이 (가) 예상 유형과 일치하지 않습니다. [** hidden **. jpa.enums.DeliverableVisibility] – Hank