本文介绍了如何获取无效数据转换的OpenJPA异常的具体细节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过连接到DB2数据库的OpenJPA得到一个 SELECT 语句的java异常。

I am getting below java exception for a SELECT statement via OpenJPA which connect to DB2 database.

可以有人指导我如何准确找到哪一列是不匹配的?

Can someone guide me on how to exactly find which column is a mismatch?

错误代码 ERRORCODE = -4461 不是很详细。

org.apache.openjpa.persistence.PersistenceException: [jcc][t4][1092][11644][3.57.82] Invalid data conversion: Wrong result column type for requested conversion. ERRORCODE=-4461, SQLSTATE=42815
    at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4827) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4787) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.jdbc.sql.DB2Dictionary.newStoreException(DB2Dictionary.java:563) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:86) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.initialize(JDBCStoreManager.java:347) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at com.ibm.ws.persistence.jdbc.kernel.WsJpaJDBCStoreManager.initialize(WsJpaJDBCStoreManager.java:147) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.DelegatingStoreManager.initialize(DelegatingStoreManager.java:112) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.ROPStoreManager.initialize(ROPStoreManager.java:57) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.BrokerImpl.initialize(BrokerImpl.java:1005) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:963) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.BrokerImpl.find(BrokerImpl.java:880) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.kernel.DelegatingBroker.find(DelegatingBroker.java:223) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at org.apache.openjpa.persistence.EntityManagerImpl.find(EntityManagerImpl.java:476) ~[com.ibm.ws.jpa.jar:1.0.1-SNAPSHOT]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) ~[na:1.6.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0]
    at java.lang.reflect.Method.invoke(Method.java:600) ~[na:1.6.0]
    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365) ~[org.springframework.orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at $Proxy45.find(Unknown Source) ~[na:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.6.0]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48) ~[na:1.6.0]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) ~[na:1.6.0]
    at java.lang.reflect.Method.invoke(Method.java:600) ~[na:1.6.0]
    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240) ~[org.springframework.orm-3.1.2.RELEASE.jar:3.1.2.RELEASE]
    at $Proxy45.find(Unknown Source) ~[na:na]

我看过和。

我还可以看到启用< property name =openjpa.jdbc.DBDictionaryvalue =db2(SupportsSelectStartIndex = true,SupportsSelectEndIndex = true)/> 在persistence.xml中创建问题。评论解决它。这可以从结果集中选择前10行。语法 SELECT TOP 10 FROM SOME_TABLE 不直接与DB2一起使用。
但不知道为什么这会导致问题。

I could also see that enabling <property name="openjpa.jdbc.DBDictionary" value="db2(SupportsSelectStartIndex=true,SupportsSelectEndIndex=true)"/> in persistence.xml creates the issue. Commenting that solves it. This is enabled for selecting top 10 rows from result set. The syntax SELECT TOP 10 FROM SOME_TABLE does not work with DB2 directly.But not really sure on why exactly this causes issue.

推荐答案

可以打开类 JDBCStoreManager在$ code> IDEA 中,在调用您的 SELECT 声明我想,你可以在调试模式下找出很容易的问题。

Can you open class JDBCStoreManager in IDEA and set breakpoint in first of line of method initialize() when call your SELECT statement? I think, you can find out what problem quite easy in debug mode.

这篇关于如何获取无效数据转换的OpenJPA异常的具体细节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:31