hi,

I tried the "Updating an Object" (using detachable property) example given
here<http://code.google.com/appengine/docs/java/datastore/creatinggettinganddeletingdata.html#Updating_an_Object>.
Later I found that even if I do not add *detachable="true" *property to my
JDO class it works without any problem. Is it ok to work without detachable
property or it just worked with my case. Following is the code I tried :



@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Data{
    @SuppressWarnings("unused")
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private String value;

    public Data(String value){
        this.value = value;
    }

    public void setValue(String value){
        this.value = value;
    }

    public String getValue(){
        return this.value;
    }
}




public class Main extends HttpServlet {

    public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException{
        doReq(req, resp);
    }

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException{
        doReq(req, resp);
    }

    private void doReq(HttpServletRequest req, HttpServletResponse resp)
throws IOException{
        Data data = new Data("some value");
        PrintWriter out = resp.getWriter();

        PersistenceManager pm = PMF.get().getPersistenceManager();
        pm.makePersistent(data);
        pm.close();

        chageValue(data);
        out.close();
    }

    @SuppressWarnings("unchecked")
    private void chageValue(Data data){
        PersistenceManager pm = PMF.get().getPersistenceManager();
        data.setValue("some other value.");
        pm.makePersistent(data);
        pm.close();
    }
}

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to