views:

309

answers:

3

I have an "Object" field in one of my JDO classes, like this:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
class Foo {
   ...
   @Persistent
   @Value(types={java.lang.Boolean.class, java.lang.String.class})
   Object bar;
   ...
}

When I tried to access this field, I got the following exception:

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)

Does anyone know if Google App Engine supports the "@Value" annotation and/or how to get around this problem?

Thanks!

A: 

According to their pages, Google App-Engine uses DataNucleus for its JDO support. From DataNucleus's site, it appears that the @Value annotation is supported, but on the 'type' attribute it says "While the attribute allows multiple values DataNucleus currently only supports the first type value"

http://www.datanucleus.org/products/accessplatform%5F1%5F1/jdo/annotations.html#Value

Addendum, it also seems that @Value is only used for maps.

William Billingsley
A: 

If using a field of type Object then the page in the DN docs is http://www.datanucleus.org/products/accessplatform%5F1%5F1/jdo/orm/objects.html which is clearly supported for RDBMS, XML, LDAP, ODBMS etc datastores. Whether Google's BigTable plugin supports it I've no idea. Perhaps if you post the stack trace of that exception you can show people where it comes from ...

--Andy (DataNucleus)

DataNucleus
+1  A: 

Thanks! Instead of using @Value, I should do this instead:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
class Foo {
   ...
   @Persistent(types={java.lang.Boolean.class, java.lang.String.class})
   Object bar;
   ...
}
Keroro