Hi,

I'm fairly new to JDO and App Engine and actually facing an odd
problem.
I'm trying to retrieve a child object with the method
pm.getObjectById(Child.class, Id) but this method throws me a
JDOObjectNotFoundException. I'm sure that the child object exists and
in facts, when I retrieve the parent object with the same method
before calling it for the child object, everything works fine.
It seems like I'm missing something so here is my code :

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Parent{

        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private String title;

        @Persistent(mappedBy="parent", defaultFetchGroup="true")
        private List<Child> childs;


        public Parent(String title, List<Child> childs) {
                super();
                this.title = title;
                this.childs = childs;
                this.configuration = configuration;
                this.utilisateur = utilisateur;
                this.commentaires = commentaires;
        }
}



@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Child{

        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private Parent parent;

        @Persistent
        private String title;

        @Persistent
        private String content;



        public Bloc(String title, String content) {
                super();
                this.title = title;
                this.content = content;
        }

}

And my code for getting the object :

PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try{
        tx.begin();
        // If I add a line here : Parent parent =
pm.getObjectById(Parent.class, parentId); the code works.
        Child child= pm.getObjectById(Child.class, childId); // childId is a
long

       //Code making changes to child object but it doesn't get that
far...

        tx.commit();
}
finally{
        if(tx.isActive())
        tx.rollback();
}
pm.close();

So here is my problem. Hope someone can help me ^^.

-- 
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