2

我在 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

为什么我会得到这个异常?

最好的问候, 投票

4

1 回答 1

2

尝试将正确的openjpa.DBDictionary 属性添加到您的 persistence.xml 文件中。

我怀疑以前当您指定 openjpa.ConnectionURL 时,JPA 会使用该 URL 来确定您使用的数据库类型。在 SystemOut.log 中搜索前缀为 CWWJP... 的消息,其中提到不知道正在使用什么类型的数据库。

于 2012-07-05T18:08:25.993 回答