我的一个JDO类中有一个“Object”字段,如下所示:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") class Foo { ... @Persistent @Value(types={java.lang.Boolean.class, java.lang.String.class}) Object bar; ... }
当我尝试访问此字段时,我遇到以下异常:
Field "Foo.bar" is declared as a reference type (interface/Object) but no implementation classes of "java.lang.Object" have been found! org.datanucleus.exceptions.NucleusUserException: Field "Foo.bar" is declared as a reference type (interface/Object) but no implementation classes of "java.lan g.Object" have been found! at org.datanucleus.metadata.MetaDataUtils.getImplementationNamesForReferenceField(MetaDataUtils.java:531) at org.datanucleus.store.mapped.mapping.ReferenceMapping.createPerImplementationColumnsForReferenceField(Re ferenceMapping.java:279) at org.datanucleus.store.mapped.mapping.ReferenceMapping.prepareDatastoreMapping(ReferenceMapping.java:205) at org.datanucleus.store.mapped.mapping.ReferenceMapping.initialize(ReferenceMapping.java:114) at org.datanucleus.store.mapped.mapping.MappingFactory.createMapping(MappingFactory.java:97) at org.datanucleus.store.mapped.mapping.AbstractMappingManager.getMapping(AbstractMappingManager.java:248) at org.datanucleus.store.appengine.DatastoreTable.initializeNonPK(DatastoreTable.java:301) at org.datanucleus.store.appengine.DatastoreTable.buildMapping(DatastoreTable.java:276) at org.datanucleus.store.appengine.DatastoreManager.newStoreData(DatastoreManager.java:329) at org.datanucleus.store.AbstractStoreManager.addClasses(AbstractStoreManager.java:788) at org.datanucleus.store.AbstractStoreManager.addClass(AbstractStoreManager.java:759) at org.datanucleus.store.mapped.MappedStoreManager.getDatastoreClass(MappedStoreManager.java:358) at org.datanucleus.store.appengine.DatastoreManager.getDatastoreClass(DatastoreManager.java:555) at org.datanucleus.store.appengine.query.DatastoreQuery.performExecute(DatastoreQuery.java:200) at org.datanucleus.store.appengine.query.JDOQLQuery.performExecute(JDOQLQuery.java:84) at org.datanucleus.store.query.Query.executeQuery(Query.java:1489) at org.datanucleus.store.query.Query.executeWithArray(Query.java:1371) at org.datanucleus.store.query.Query.execute(Query.java:1344) at org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:221)
有谁知道Google App Engine是否支持“@Value”注释和/或如何解决此问题?
谢谢!
答案 0 :(得分:1)
谢谢!而不是使用@Value,我应该这样做:
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true") class Foo { ... @Persistent(types={java.lang.Boolean.class, java.lang.String.class}) Object bar; ... }
答案 1 :(得分:0)
根据他们的网页,Google App-Engine使用DataNucleus来支持JDO。从DataNucleus的网站看,似乎支持@Value注释,但在'type'属性上它显示“虽然属性允许多个值,DataNucleus目前仅支持第一个类型值”
http://www.datanucleus.org/products/accessplatform_1_1/jdo/annotations.html#Value
附录,似乎@Value仅用于地图。
答案 2 :(得分:0)
如果使用Object类型的字段,则DN文档中的页面为 http://www.datanucleus.org/products/accessplatform_1_1/jdo/orm/objects.html 这显然支持RDBMS,XML,LDAP,ODBMS等数据存储。 Google的BigTable插件是否支持它我不知道。也许如果您发布该异常的堆栈跟踪,您可以向人们展示它来自哪里......
- 安迪(DataNucleus)