Your problem seems to be related to this open gwt issue: http://code.google.com/p/google-web-toolkit/issues/detail?id=4976
Please star the issue to raise its attention. The workaround is not using 1:n relationships with GWT + GAE + JDO. Cheers, Fred On 26 Aug., 23:12, hampole <rhamp...@gmail.com> wrote: > I am trying to develop GAE application. I am using the latest GWT > SDK(2.0.4) AND App Engine SDK(1.3.6) on Eclipse3.4. I am having > problem in saving a child object "Appointment" and the parent object > is "Employee". Each Employee has many appointments and and each > appointment has one employee associated with. I have pasted the Client > code and the server code here. Please help and see what I am missing > here. I tried many different ways without success. When I retrieve the > appointments, the employee is always null. I appreciate any help or > some example that I can try. Thanks. > > //Client code > public class AppointmentCreateWidget extends Composite { > > private static AppointmentCreateWidgetUiBinder uiBinder = GWT > .create(AppointmentCreateWidgetUiBinder.class); > > interface AppointmentCreateWidgetUiBinder extends > UiBinder<Widget, AppointmentCreateWidget> { > } > > @UiField Button btnSaveAppointment; > @UiField TextBox tbxSubject; > @UiField ListBox lbxRoom; > @UiField ListBox lbxHost; > @UiField DateBox dbAppointStartDate; > @UiField DateBox dbAppointEndDate; > @UiField ListBox lbxStartTimeHr; > @UiField ListBox lbxEndTimeHr; > @UiField ListBox lbxStartTimeMi; > @UiField ListBox lbxEndTimeMi; > > private final AppointmentServiceAsync appointService = > (AppointmentServiceAsync) GWT.create(AppointmentService.class); > private final List<Visitor> visitors = new ArrayList<Visitor>(); > > public AppointmentCreateWidget() { > initWidget(uiBinder.createAndBindUi(this)) > } > > @UiHandler("btnSaveAppointment") > void onClick(ClickEvent e) { > addAppointment(); > } > > private void addAppointment() { > String subject = tbxSubject.getText().toUpperCase().trim(); > Date startdate = dbAppointStartDate.getValue(); > Date enddate = dbAppointEndDate.getValue(); > String starttime = > lbxStartTimeHr.getValue(lbxStartTimeHr.getSelectedIndex()).toString() > + > lbxStartTimeMi.getValue(lbxStartTimeMi.getSelectedIndex()); > String endtime = > lbxEndTimeHr.getValue(lbxEndTimeHr.getSelectedIndex()).toString() + > lbxEndTimeMi.getValue(lbxEndTimeMi.getSelectedIndex()); > String room = > lbxRoom.getValue(lbxRoom.getSelectedIndex()).toString(); > String key = lbxHost.getValue(lbxHost.getSelectedIndex()); > DateTimeFormat dateFormat = DateTimeFormat.getShortDateFormat(); > > try { > createAppointment(subject, startdate, enddate, starttime, > endtime, key, visitors); > } > catch(Exception ex) { > Window.alert("Save Appointment failed: " + ex.toString()); > } > } > > private void createAppointment(String subject, Date startdate, Date > enddate, String starttime, String endtime, String empID, List<Visitor> > visitor) { > appointService.addAppointment(subject,startdate, enddate, > starttime, endtime, empID, visitor, new AsyncCallback<Void>() { > public void onFailure(Throwable error) { > Window.alert("Unable to create Appointment." + > error.getMessage()); > } > public void onSuccess(Void ignore) { > } > }); > } > > } > > //ServiceImpl > public class AppointmentServiceImpl extends RemoteServiceServlet > implements AppointmentService { > /** > * > */ > private static final long serialVersionUID = 1L; > > public void addAppointment(String subject, Date appointStartDate, > Date appointEndDate, String startTime, String endTime, String empID, > List<Visitor> visitors) throws NotLoggedInException { > PersistenceManager pm = getPersistenceManager(); > //get employee > Employee emp = pm.getObjectById(Employee.class, empID); > > Appointment newAppoint = new Appointment(subject, > appointStartDate, appointEndDate, startTime, endTime); > newAppoint.setVisitors(visitors); > newAppoint.setEmployee(emp); > emp.getAppointments().add(newAppoint); > > try { > pm.makePersistent(emp); > } finally { > pm.close(); > } > } > > private PersistenceManager getPersistenceManager() { > return PMF.get().getPersistenceManager(); > } > > } > > //Employee Bean > @PersistenceCapable(identityType = IdentityType.APPLICATION, > detachable = "true") > public class Employee implements IsSerializable, IValidatable { > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > @Extension(vendorName="datanucleus", key="gae.encoded-pk", > value="true") > private String employeeKey; > > @NotEmpty(message="You must specify First Name") > @Length(minimum=3) > @Persistent > private String firstName; > > @NotEmpty(message="You must specify Last Name") > @Length(minimum=3) > @Persistent > private String lastName; > > @Persistent > private String title; > > @NotEmpty(message="You must specify Email Address") > @Length(minimum=3) > @Persistent > private String email; > > @Persistent > private String department; > > @Persistent > private String phone; > > @Persistent > private String extension; > > @Persistent > private String companyName; > > @Persistent(mappedBy = "employee") > @Element(dependent = "true") > private List<Appointment> appointments; > > public Employee(String firstName, String lastName, String title, > String email, > String phone, String extension, String department, String > companyName) { > this(); > this.firstName = firstName; > this.lastName = lastName; > this.title = title; > this.email = email; > this.department = department; > this.phone = phone; > this.extension = extension; > this.companyName = companyName; > } > > //getters and setters > > } > > //Appointment Bean > @PersistenceCapable(identityType = IdentityType.APPLICATION, > detachable = "true") > public class Appointment implements IsSerializable, IValidatable { > > @PrimaryKey > @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) > @Extension(vendorName="datanucleus", key="gae.encoded-pk", > value="true") > private String appointKey; > > @Persistent > private String subject; > > @NotEmpty(message="You must specify Start Time") > @Persistent > private String startTime; > > @NotEmpty(message="You must specify End Time") > @Persistent > private String endTime; > > @NotEmpty(message="You must specify Start Date") > @Persistent > private Date appointmentStartDate; > > @NotEmpty(message="You must specify End Date") > @Persistent > private Date appointmentEndDate; > > @Persistent > private Employee employee; > > @Persistent > private List<Visitor> visitors = new ArrayList<Visitor>(); > > public Appointment(String subject, Date appointStartDate, Date > appointEndDate, String startTime, String endTime, Employee employee, > List<Visitor> visitors) > { > this(); > this.subject = subject; > this.startTime = startTime; > this.endTime = endTime; > this.appointmentStartDate = appointStartDate; > this.appointmentEndDate = appointEndDate; > this.employee = employee; > this.visitors = visitors; > } > > //getters and setters > > } -- 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 google-appengine-j...@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.