Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model can not have field of type com.google.appengine.api.datastore.Key #14

Closed
GoogleCodeExporter opened this issue Sep 2, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

    According to the document (
http://sites.google.com/site/slim3appengine/slim3-datastore/defining-data-classe
s/core-value-types
),the com.google.appengine.api.datastore.Key can be used as field type.
But a model (see the SomeModel example below) contains a Key field throws
the IllegalArgumentException exception when Datastore.put is called to
persist the entity of that class.

@Model(schemaVersion = 1)
public class SomeModel {

    @Attribute(primaryKey = true)
    private Key key;
    ...
    private Key someOtherKey;
    ...
}

Stack trace

java.lang.IllegalArgumentException: The meta data of the
model(com.google.appengine.api.datastore.Key) is not found.
    at org.slim3.datastore.DatastoreUtil.createModelMeta(DatastoreUtil.java:1295)
    at org.slim3.datastore.DatastoreUtil.getModelMeta(DatastoreUtil.java:1222)
    at org.slim3.datastore.DatastoreUtil.modelToEntity(DatastoreUtil.java:1398)
    at org.slim3.datastore.DatastoreUtil.modelsToEntities(DatastoreUtil.java:1426)
    at org.slim3.datastore.Datastore.put(Datastore.java:2324)
...
[omitted]

Original issue reported on code.google.com by mylee...@gmail.com on 6 Apr 2010 at 9:43

@GoogleCodeExporter
Copy link
Author

I cannot reproduce it. Could you elaborate on that?

My model:
package slim3.demo.model;

import java.io.Serializable;
import org.slim3.datastore.Attribute;
import org.slim3.datastore.Model;
import com.google.appengine.api.datastore.Key;

@Model(schemaVersion = 1)
public class SomeModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Attribute(primaryKey = true)
    private Key key;

    private Key someOtherKey;

    public Key getKey() {
        return key;
    }

    public void setKey(Key key) {
        this.key = key;
    }

    public Key getSomeOtherKey() {
        return someOtherKey;
    }

    public void setSomeOtherKey(Key someOtherKey) {
        this.someOtherKey = someOtherKey;
    }
}

My test case:
package slim3.demo.model;

import org.junit.Test;
import org.slim3.datastore.Datastore;
import org.slim3.tester.AppEngineTestCase;

public class SomeModelTest extends AppEngineTestCase {

    private SomeModel model = new SomeModel();

    @Test
    public void test() throws Exception {
        Datastore.put(model);
    }
}

Original comment by higaya...@gmail.com on 6 Apr 2010 at 11:12

@GoogleCodeExporter
Copy link
Author

I made a stupid mistake. I mistakenly put a Key into an list and use the list 
in a
Datastore.put(tx, list) call.

Please remove this issue. And I am sorry for wasting your time.

Original comment by mylee...@gmail.com on 6 Apr 2010 at 12:57

@GoogleCodeExporter
Copy link
Author

Please tell me before remove this issue. The Slim3 forum is full of junk
advertisement and it seems there are very few people discussing there. If I have
additional questions, should/may I ask question in English in Slim3 Japanese 
forum?
Thanks!

Original comment by mylee...@gmail.com on 7 Apr 2010 at 12:22

@GoogleCodeExporter
Copy link
Author

Please feel free to post questions in Slim3 English forum if you have any 
questions.

Original comment by higaya...@gmail.com on 7 Apr 2010 at 2:02

@GoogleCodeExporter
Copy link
Author

Thanks! I understand.

Slim3 is a good framework. GJ!

PS: Since I have read the latest message, you can close (or remove) this issue.

Original comment by mylee...@gmail.com on 7 Apr 2010 at 9:54

@GoogleCodeExporter
Copy link
Author

Original comment by higaya...@gmail.com on 8 Apr 2010 at 3:38

  • Changed state: WontFix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant