Migration 2.0-RC: Kind with extends

36 views
Skip to first unread message

Sydney

unread,
Nov 28, 2012, 2:01:46 PM11/28/12
to twig-p...@googlegroups.com

I get an exception because the kind has already been mapped. A and B both extend DatastoreObject.

Caused by: java.lang.IllegalArgumentException: Kind name com.server.model.domain.DatastoreObject was already mapped to class com.server.model.domain.A
    at com.google.code.twig.configuration.DefaultConfiguration.registerTypeName(DefaultConfiguration.java:33)
public class AnnotationObjectDatastoreProvider implements
        Provider<ObjectDatastore> {

    static {
        ObjectDatastoreFactory.register(A.class);
        ObjectDatastoreFactory.register(B.class);
    }

    // don't index fields by default
    private final Boolean indexed = false;

    @Override
    public ObjectDatastore get() {
        ObjectDatastore datastore = new AnnotationObjectDatastore(

                Settings.defaults(), 0, indexed);
        return datastore;
    }

}

Ryan Chazen

unread,
Nov 29, 2012, 12:36:35 PM11/29/12
to twig-p...@googlegroups.com
Hey

I had the same issue - seems to be caused by putting @Entity on a class.
To fix, either remove @Entity from the class (you don't need it) or have @Entity(kind="unique string") - if you don't specify @Entity, it will use the simple class name. If you specify @Entity but no kind, then it will use a blank string and break.

In your case, it looks like you have @Entity(kind="com.server.model.domain.DatastoreObject") on the parent class of A and B - so both A and B inherit that kind name from the parent. So you need to specify a unque kind for both A and B, or remove @Entity from the parent class...

I think, anyway!
Reply all
Reply to author
Forward
0 new messages