开发者

Adding functions to my Google app engine app made with Java and JDO

开发者 https://www.devze.com 2023-04-04 14:50 出处:网络
Here is my testing app: http://caoscoding.appspot.com login: admin pass: test Is an simple app where you insert some data and get开发者_如何学JAVA out a table, of that data, that\'s all.

Here is my testing app: http://caoscoding.appspot.com

login: admin pass: test

Is an simple app where you insert some data and get开发者_如何学JAVA out a table, of that data, that's all.

I want to add 2 more functions: modify an entry and delete an entry.

How should I write these 2 functions? I don't have any good idea any more..

The orm is JDO, and is all made with java.

Please suggest any idea to do so, or any code snippet. I don't know how to edit, save and put the updated entry in the datastore. And don't know how to delete it either, I am really stuck here.


To edit an entry you would do something like:

PersistenceManager pm = PMF.get().getPersistenceManager();
// some query to retrieve your object/entry
...
// then make the changes you want to your object
....
// then write it back as per below:
pm.makePersistent(myObject);

The call to the persistence manager to delete an entry would similarly be:

pm.deletePersistent(myObject);
0

精彩评论

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

关注公众号