It works perfectly.

Thank you

Cid

On 6 août, 20:19, "Jason (Google)" <[email protected]> wrote:
> This may be related to the fetch group of the classes field. Try replacing
> the appropriate lines in School.java with this:
> @Persistent(mappedBy = "school", defaultFetchGroup = "true")
> private List<Classe> classes = new ArrayList<Classe>();
>
> Let me know if this works for you.
>
> - Jason
>
> 2009/8/4 Cédric Chevarier <[email protected]>
>
>
>
> > Hi,
>
> > I have a problem with a one-to-many relationship. Here is my code
>
> > Class School :
>
> > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > public class School implements IsSerializable{
> >       �...@primarykey
> >       �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >        private Key key;
> >       �...@persistent
> >        private String name;
> >       �...@persistent
> >        private String structure;
> >       �...@persistent(mappedBy = "school")
> >        private List<Classe> classes = new ArrayList<Classe>();
> > //.....
> > }
>
> > Class Classe :
>
> > @PersistenceCapable(identityType = IdentityType.APPLICATION)
> > public class Classe implements IsSerializable{
> >       �...@persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
> >       �...@primarykey
> >        private Key key;
> >       �...@persistent
> >        private String name;
> >       �...@persistent
> >        private School school;
> >       �...@persistent
> >        private String schoolName;
> > //....
> > }
>
> > Code to add a Classe (it's work)
>
> > public String addClasse(Classe classe) {
> >                PersistenceManager pm = PMF.get().getPersistenceManager();
> >                Key key2 =
> > KeyFactory.createKey(School.class.getSimpleName(),
> > classe.getSchoolName());
> >                School school2 = (School) pm.getObjectById(School.class,
> > key2);
> >                Key key = new
> > KeyFactory.Builder(School.class.getSimpleName(),
> > school2
>
> >  .getName()).addChild(Classe.class.getSimpleName(),
> >                                                classe.getName()).getKey();
> >                classe.setKey(key);
> >                school2.addClasses(classe);
> >                pm.makePersistent(school2);
> >                pm.close();
> >                return "ok";
> >        }
>
> > Code to get all Classes (It's the problem)
>
> > public List<Classe> getClasseSchool(String schoolName){
> >                PersistenceManager pm = PMF.get().getPersistenceManager();
> >                Key key = KeyFactory.createKey(School.class.getSimpleName(),
> > schoolName);
> >                School school = (School) pm.getObjectById(School.class,
> > key);
> >                List<Classe> classeList = new ArrayList<Classe>();
> >                classeList = school.getClasses();
> >                return classeList;
>
> >        }
>
> > When I try to retreive the ClassList I have got this error :
> >  [ERROR] Uncaught exception escaped
> > java.lang.NullPointerException: null
>
> > Can you help me ??
>
> > Cédric
>
> > OS : Mac OS X 10.5
> > App Engine SDK : 1.2.2
> > GWT SDK : 1.7.0
>
>
--~--~---------~--~----~------------~-------~--~----~
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