我在WebSphere Application Server 8上使用OpenJPA 2.1.2。 我首先使用:
<property name="openjpa.ConnectionUserName" value="xxx" />
<property name="openjpa.ConnectionPassword" value="yyyy" />
<property name="openjpa.ConnectionURL" value="zzz">
以持久性XML定义我的数据库连接。
现在我更改了这个,并使用了我在WebSphere Applicaiton Server管理控制台中定义的数据源。
我删除了添加的
属性标记<jta-data-source>java:comp/env/jdbc/name/mysql</jta-data-source>
但是现在,当我进行查询时,我得到以下JPA异常:
<openjpa-2.1.2-SNAPSHOT-r422266:1227818 fatal general error> org.apache.openjpa.persistence.PersistenceException: DSRA9500E: Negative values are not allowed for fetch size.
FailedObject: SELECT u FROM user_table u WHERE lower(u.username) = lower(:name) [java.lang.String]
at org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4878)
at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4838)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:118)
at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:70)
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.handleCheckedException(SelectResultObjectProvider.java:155)
at org.apache.openjpa.datacache.QueryCacheStoreQuery$CachingResultObjectProvider.handleCheckedException(QueryCacheStoreQuery.java:701)
at org.apache.openjpa.lib.rop.WindowResultList.<init>(WindowResultList.java:64)
at org.apache.openjpa.jdbc.kernel.JDBCFetchConfigurationImpl.newResultList(JDBCFetchConfigurationImpl.java:292)
at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1251)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:331)
at gui.jpa.service.JPAQueries.getUser(JPAQueries.java:196)
at security.ContentAuthorisation.authorisedForAcess(ContentAuthorisation.java:10)
at web.app.auth.RequestFilter.doFilter(RequestFilter.java:31)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:192)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:89)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:926)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1023)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3703)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnecti at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnecti
onInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture$1.run(AsyncChannelFuture.java:205)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1659)
Caused by: java.sql.SQLDataException: DSRA9500E: Negative values are not allowed for fetch size.
at com.ibm.ws.rsadapter.jdbc.WSJdbcStatement.setFetchSize(WSJdbcStatement.java:1935)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setFetchSize(DelegatingPreparedStatement.java:242)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.setFetchSize(DelegatingPreparedStatement.java:242)
at org.apache.openjpa.jdbc.sql.SQLBuffer.prepareStatement(SQLBuffer.java:568)
at org.apache.openjpa.jdbc.sql.SelectImpl.prepareStatement(SelectImpl.java:481)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:418)
at com.ibm.ws.persistence.jdbc.sql.SelectImpl.execute(SelectImpl.java:89)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:391)
at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:427)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220)
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94)
at org.apache.openjpa.datacache.QueryCacheStoreQuery$CachingResultObjectProvider.open(QueryCacheStoreQuery.java:644)
at org.apache.openjpa.lib.rop.WindowResultList.<init>(WindowResultList.java:57)
... 32 more
为什么我会收到此异常?
致敬,Veote
答案 0 :(得分:2)
尝试将正确的openjpa.DBDictionary property添加到persistence.xml文件中。
我怀疑之前当您指定openjpa.ConnectionURL时,JPA会使用该URL来确定您正在使用的数据库类型。在您的SystemOut.log中搜索带有前缀CWWJP的消息,其中提到了一些不知道正在使用什么类型的数据库的消息。