gpt4 book ai didi

java - Datanucleus JDO 将字符串映射到 App Engine 中的 MySQL 类型 bigint

转载 作者:行者123 更新时间:2023-12-01 13:30:41 26 4
gpt4 key购买 nike

我正在尝试通过 JDO 从我的 App Engine 应用程序访问数据存储区和 Cloud SQL。如果我将主键类型设置得那么长,则一切都可以在 Cloud SQL 中正常运行,但数据存储区不起作用,并且如果我将主键设置为 String 并希望将其转换为 JDBC 类型“Bigint”,则在尝试访问时会收到以下错误云 SQL:

javax.jdo.JDOUserException: Exception thrown while loading remaining rows of query
at org.datanucleus.api.jdo.JDOAdapter.getUserExceptionForException(JDOAdapter.java:1085)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.closingConnection(ForwardQueryResult.java:273)
at org.datanucleus.store.query.AbstractQueryResult.disconnect(AbstractQueryResult.java:108)
at org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult.disconnect(AbstractRDBMSQueryResult.java:69)
at org.datanucleus.store.rdbms.query.JDOQLQuery$2.transactionPreClose(JDOQLQuery.java:698)
at org.datanucleus.store.connection.AbstractManagedConnection.transactionPreClose(AbstractManagedConnection.java:92)
at org.datanucleus.store.connection.ConnectionManagerImpl$2.transactionPreRollBack(ConnectionManagerImpl.java:333)
at org.datanucleus.TransactionImpl.internalPreRollback(TransactionImpl.java:523)
at org.datanucleus.TransactionImpl.rollback(TransactionImpl.java:446)
at org.datanucleus.api.jdo.JDOTransaction.rollback(JDOTransaction.java:180)
at de.studienarbeit3.dokumente.DokumentListServlet.doPost(DokumentListServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:487)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
NestedThrowablesStackTrace:
Somehow org.datanucleus.store.rdbms.mapping.BigIntRDBMSMapping.getLong() was called on the mapping for field="de.studienarbeit3.dokumente.Dokument.did", which should have been impossible!
org.datanucleus.exceptions.NucleusException: Somehow org.datanucleus.store.rdbms.mapping.BigIntRDBMSMapping.getLong() was called on the mapping for field="de.studienarbeit3.dokumente.Dokument.did", which should have been impossible!
at org.datanucleus.store.mapped.mapping.AbstractDatastoreMapping.getLong(AbstractDatastoreMapping.java:110)
at org.datanucleus.store.rdbms.mapping.BigIntRDBMSMapping.getString(BigIntRDBMSMapping.java:182)
at org.datanucleus.store.mapped.mapping.SingleFieldMapping.getString(SingleFieldMapping.java:202)
at org.datanucleus.store.rdbms.fieldmanager.ResultSetGetter.fetchStringField(ResultSetGetter.java:137)
at org.datanucleus.identity.IdentityUtils.getApplicationIdentityForResultSetRow(IdentityUtils.java:125)
at org.datanucleus.store.rdbms.query.PersistentClassROF.getIdentityForResultSetRow(PersistentClassROF.java:542)
at org.datanucleus.store.rdbms.query.PersistentClassROF.getObjectForApplicationId(PersistentClassROF.java:473)
at org.datanucleus.store.rdbms.query.PersistentClassROF.getObject(PersistentClassROF.java:371)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.nextResultSetElement(ForwardQueryResult.java:176)
at org.datanucleus.store.rdbms.query.ForwardQueryResult$QueryResultIterator.next(ForwardQueryResult.java:380)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.processNumberOfResults(ForwardQueryResult.java:138)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.advanceToEndOfResultSet(ForwardQueryResult.java:159)
at org.datanucleus.store.rdbms.query.ForwardQueryResult.closingConnection(ForwardQueryResult.java:261)
at org.datanucleus.store.query.AbstractQueryResult.disconnect(AbstractQueryResult.java:108)
at org.datanucleus.store.rdbms.query.AbstractRDBMSQueryResult.disconnect(AbstractRDBMSQueryResult.java:69)
at org.datanucleus.store.rdbms.query.JDOQLQuery$2.transactionPreClose(JDOQLQuery.java:698)
at org.datanucleus.store.connection.AbstractManagedConnection.transactionPreClose(AbstractManagedConnection.java:92)
at org.datanucleus.store.connection.ConnectionManagerImpl$2.transactionPreRollBack(ConnectionManagerImpl.java:333)
at org.datanucleus.TransactionImpl.internalPreRollback(TransactionImpl.java:523)
at org.datanucleus.TransactionImpl.rollback(TransactionImpl.java:446)
at org.datanucleus.api.jdo.JDOTransaction.rollback(JDOTransaction.java:180)
at de.studienarbeit3.dokumente.DokumentListServlet.doPost(DokumentListServlet.java:82)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
at com.google.appengine.api.socket.dev.DevSocketFilter.doFilter(DevSocketFilter.java:74)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.ResponseRewriterFilter.doFilter(ResponseRewriterFilter.java:123)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.HeaderVerificationFilter.doFilter(HeaderVerificationFilter.java:34)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:63)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:43)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:125)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectRequest(DevAppServerModulesFilter.java:366)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doDirectModuleRequest(DevAppServerModulesFilter.java:349)
at com.google.appengine.tools.development.DevAppServerModulesFilter.doFilter(DevAppServerModulesFilter.java:116)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
at com.google.appengine.tools.development.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:97)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at com.google.appengine.tools.development.JettyContainerService$ApiProxyHandler.handle(JettyContainerService.java:487)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

我的package.jdo如下:

  <jdo>
<package name="de.studienarbeit3.dokumente">
<class name="Autor" detachable="true" identity-type="application">
<datastore-identity value-strategy="identity"/>
<field name="aid" primary-key="true" persistence-modifier="persistent" value-strategy="identity"/>
<field name="vorname"/>
<field name="nachname" />
<field name="dokumente" />

</class>
<class name="Dokument" detachable="true" identity-type="application">
<datastore-identity value-strategy="identity"/>
<field name="did" primary-key="true" persistence-modifier="persistent" value-strategy="identity">
</field>
<field name="autor"/>
<field name="titel"/>
<field name="text"/>
<field name="datum"/>

</class>
</package>
</jdo>

package-sql.orm 是这样的:

<orm>
<package name="de.studienarbeit3.dokumente">
<class name="Autor" detachable="true" persistence-modifier="persistence-capable" table="Autor">
<datastore-identity value-strategy="identity"/>
<field name="aid" primary-key="true" persistence-modifier="persistent" value-strategy="identity">
<column name="aid" jdbc-type="bigint" length="20"/>
</field>
<field name="vorname" persistence-modifier="persistent">
<column name="vorname"/>
</field>
<field name="nachname" persistence-modifier="persistent">
<column name="nachname"/>
</field>
<field name="dokumente" persistence-modifier="persistent" mapped-by="autor">
<collection element-type="de.studienarbeit3.dokumente.Dokument"/>
</field>
</class>
<class name="Dokument" detachable="true" persistence-modifier="persistence-capable" table="Dokument">
<datastore-identity />
<field name="did" primary-key="true" persistence-modifier="persistent" value-strategy="identity">
<column name="did" jdbc-type="bigint" length="20" />
</field>
<field name="autor" persistence-modifier="persistent" default-fetch-group="true">
<column name="autor" jdbc-type="bigint" length="20"/>
<foreign-key name="DOKUMENTAUTOR_FK" delete-action="restrict"/>
</field>
<field name="titel" persistence-modifier="persistent">
<column name="titel"/>
</field>
<field name="text" persistence-modifier="persistent">
<column name="text"/>
</field>
<field name="datum" persistence-modifier="persistent">
<column name="datum"/>
</field>
</class>
</package>
</orm>

有什么办法可以解决这个问题吗?我尝试过这个插件但没有成功:http://blog.wp.weightpoint.se/2012/03/01/portable-owned-jdo-relations-appengine/

根据这个http://www.datanucleus.org/servlet/jira/browse/NUCRDBMS-597它已在 Datanucleus 3.1.0.m4 中修复。 GAE 有 3.1.3。但它不起作用。任何帮助都会非常有帮助,谢谢

最佳答案

首先,您在那里使用不受支持的旧版本。其次,如果你检查 JIRA,你还会看到 http://www.datanucleus.org/servlet/jira/browse/NUCRDBMS-705

解决方案:使用最新版本(是的,“GAE CloudSQL”可能正在打包一些古老的版本,因为他们的 GAE/Datastore 插件需要该版本,但是您可以轻松地使用 MySQL 的最新版本,而您不需要需要他们的插件)

关于java - Datanucleus JDO 将字符串映射到 App Engine 中的 MySQL 类型 bigint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21588107/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com