I don't know if this is it but your problem could be that you are using setters to set first and last name which is the way you are supposed to do it (so that the enhancer can find all places where properties may be modified) but you are directly setting the student property instead of using a setter method and therefore the code may not be able to determine that the student field has been dirtied. Try using a setter method for student instead.
Stephen www.cortexconnect.com On Mon, Aug 29, 2011 at 6:35 AM, Bat <[email protected]> wrote: > I've 2 simple classes : > > public class Student { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > com.google.appengine.api.datastore.Key key; > @Persistent > public String firstName; > @Persistent > public String lastName; > } > And > > public class Teacher { > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > com.google.appengine.api.datastore.Key key; > @Persistent > public String firstName; > @Persistent > public String lastName; > @Persistent > public com.google.appengine.api.datastore.Key student; > } > > First, I create a Teacher with only the fields 'firstname' & > 'lastname' filled. It works. Then, I update my teacher with this > code : > > Transaction tx = pm.currentTransaction(); > tx.begin(); > Teacher a = pm.getObjectById(Teacher.class, > KeyFactory.stringToKey( the_key)); > if(a != null) { > try { > a.setFirstName("test"); > a.setLastName("test"); > a.student = KeyFactory.stringToKey( req.getParameter("student101- > key")); > tx.commit(); > } > } > pm.close(); > } > } > After this transaction, the fields "firstname" & "lastname" are > correctly updated. However, the field "student" is still null. Do you > know Why? > > Thank you very much > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" 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?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" 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?hl=en.
