Hi,

Those two are equivalent Java constructs, and it should not be the
solution to your problem. Have you tried rewriting your code to the
original (having the return statement within the try block) and run it
again? Are you sure you have not changed anything else?

Marton


On Sep 21, 6:29 pm, Dhamu <kernel...@gmail.com> wrote:
> my bad.. my stupid programming style I guess....
>
> I changed from
>
> PersistenceManager pm = ...getPersistenceManager();
> try {
>         return pm.getObjectById(MyModel.class, id);} finally {
>
>         pm.close();
>
> }
>
> to
>
> PersistenceManager pm = ...getPersistenceManager();
> try {
>         MyModel m = pm.getObjectById(MyModel.class, id);
>         return pm.detachCopy(m);
>
> } finally {
>
>         pm.close();
>
> }
>
> and still it didn't work. and then I changed to
>
> PersistenceManager pm = ...getPersistenceManager();
> MyModel m = null, detached = null;
> try {
>         m = pm.getObjectById(MyModel.class, id);
>         detached = pm.detachCopy(m);
>
> } finally {
>
>         pm.close();}
>
> return detached;
>
> and hurray!!! it works now.. Thanks anyways...
> Anybody know why?
>
> On Sep 21, 2:42 pm, Dhamu <kernel...@gmail.com> wrote:
>
> > // MyModel
> > String id
> > List<String> values
> > List<Long> scores;
>
> > // get(id)
> > PersistenceManager pm = ...getPersistenceManager();
> > try {
> >         return pm.getObjectById(MyModel.class, id);
>
> > } finally {
> >         pm.close();
> > }
>
> > // store(obj);
> > PersistenceManager pm = ...getPersistenceManager();
> > try {
> >         pm.makePersistent(obj);
>
> > } finally {
> >         pm.close();
> > }
>
> > MyModel m = new MyModel();
> > m.setId("key1");
> > m.addValue("value1");
> > m.addScore(100);
> > store(m);
>
> > Datastore (snapshot): I can see the following values in datastore
> > (thats ok).
> > key1, [value1], [100]
>
> > if I call get("key1") and print the properties, it prints only the id
> > but values and scores are always null
>
> > // I am trying to update like this
> > MyModel m = get("key1"); // values and scores property are null, only
> > id has the value.
> > m.addValue("value2");
> > m.addScore(200);
> > store(m); // this always replaces the old row in database.
> > i.e. now the database has only
> > key1, [value2], [200]
>
> > Why? Please help. I might be doing something wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to