问题
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?
The error code ERRORCODE=-4461
does not really elaborate much.
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]
I have looked at this and this.
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.
回答1:
Can someone guide me on how to exactly find which column is a mismatch?
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.
来源:https://stackoverflow.com/questions/34270152/how-to-get-the-exact-details-of-openjpa-exception-for-invalid-data-conversion