开发者

How do I dynamically create class and persist it to the Google App Engine?

开发者 https://www.devze.com 2023-02-28 02:24 出处:网络
How do I create persist-able class dynamically and persist it to the Goo开发者_JAVA百科gle App Engine datastoreIf you mean you don\'t know beforehand what fields/properties will be persisted then you

How do I create persist-able class dynamically and persist it to the Goo开发者_JAVA百科gle App Engine datastore


If you mean you don't know beforehand what fields/properties will be persisted then you can use the Datastore API to create and persist entities on the fly.

Entity entity = new Entity("User"); // specify the entity kind
entity.setProperty("name", "someuser"); // add some properties
entity.setProperty("email", "some@user.com");
DatastoreServiceFactory.getDatastoreService().put(entity); //save it

However if you actually want to create 'class' dynamically then this answer would not help.

0

精彩评论

暂无评论...
验证码 换一张
取 消