sorry guys, my bad. again !
On Sat, Sep 26, 2009 at 10:20 AM, Prashant <[email protected]> wrote:
> Hi,
>
>
> I tried to create an object child relationship, both (object and child) are
> getting saved properly but while retrieving them back I am getting
> nullPointerException for child. Please help, following is my code:
>
>
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class Data{
>
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> Long id;
>
> @Persistent
> MyData mydata;
> }
>
>
>
>
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class MyData{
>
> @PrimaryKey
> @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> private Key key;
>
> @Persistent(defaultFetchGroup = "true")
> String myValue;
> }
>
>
>
>
> public class Main extends HttpServlet {
>
> public void doGet(HttpServletRequest req, HttpServletResponse resp)
> throws IOException{
> /*
> Data data = new Data();
> data.mydata = new MyData();
> data.mydata.myValue = "some value";
> PersistenceManager pm = PMF.get().getPersistenceManager();
> pm.makePersistent(data);
> resp.getWriter().print("Done");
> */
>
> PersistenceManager pm = PMF.get().getPersistenceManager();
> Data data = pm.getObjectById(Data.class, 3);
> resp.getWriter().print(data.mydata.myValue); //
> NullPointerException
> 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
-~----------~----~----~----~------~----~------~--~---