Hi, I have created 3 classes as follow:
@PersistenceCapable(identityType = IdentityType.APPLICATION) public class Department { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String deptName; // Getters and setters } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class Person { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private String firstName; @Persistent private String lastName; @Persistent private Department department; @Persistent(mappedBy = "employee") private List<MonthlySalary> monthlySalaryList; // Getters and setters } @PersistenceCapable(identityType = IdentityType.APPLICATION) public class MonthlySalary { @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private Date salaryDate; @Persistent private double amount; @Persistent private Person employee; // Getters and setters } Now, I have used JDO to store these objects in following way: Department department = null; PersistenceManager pm = PMF.get().getPersistenceManager(); Person employee = null; try { // ///////////////////////////// Employee KeyFactory.Builder keyBuilder = new KeyFactory.Builder (Department.class.getSimpleName(), "D11"); department = new Department(); department.setKey(keyBuilder.getKey()); department.setDeptName("ennovate"); keyBuilder = new KeyFactory.Builder(Person.class.getSimpleName(), "E01"); employee = new Person(); employee.setKey(keyBuilder.getKey()); employee.setFirstName("Chetan"); employee.setLastName("Soni"); employee.setDepartment(department); pm.makePersistent(employee); } catch (Exception e) { e.printStackTrace(); } finally { pm.close(); } pm = PMF.get().getPersistenceManager(); try { // ///////////////////////////// Monthly Salary 1 KeyFactory.Builder keyBuilder = new KeyFactory.Builder (Person.class.getSimpleName(), "E01"); keyBuilder.addChild(MonthlySalary.class.getSimpleName(), "M01"); MonthlySalary monthlySalary = new MonthlySalary(); monthlySalary.setKey(keyBuilder.getKey()); monthlySalary.setAmount(50000); monthlySalary.setEmployee(pm.getObjectById(Person.class, "E01")); monthlySalary.setSalaryDate(new Date()); pm.makePersistent(monthlySalary); } catch (Exception e) { e.printStackTrace(); } finally { pm.close(); } pm = PMF.get().getPersistenceManager(); try { // ///////////////////////////// Monthly Salary 2 KeyFactory.Builder keyBuilder = new KeyFactory.Builder (Person.class.getSimpleName(), "E01"); keyBuilder.addChild(MonthlySalary.class.getSimpleName(), "M02"); MonthlySalary monthlySalary = new MonthlySalary(); monthlySalary.setKey(keyBuilder.getKey()); monthlySalary.setAmount(60000); monthlySalary.setEmployee(pm.getObjectById(Person.class, "E01")); monthlySalary.setSalaryDate(new Date()); pm.makePersistent(monthlySalary); } catch (Exception e) { e.printStackTrace(); } finally { pm.close(); } Now When I access MonthlySalary using: String query1 = "select from " + MonthlySalary.class.getName(); List<MonthlySalary> alist = (List<MonthlySalary>) pm.newQuery (query1).execute(); for(MonthlySalary monthlySalary : alist) { // Giving error at this line System.out.println(monthlySalary.getEmployee().getFirstName()); } It's giving me the error: org.datanucleus.exceptions.NucleusUserException: Field org.example.wa.MonthlySalary.employee should be able to provide a reference to its parent but the entity does not have a parent. Did you perhaps try to establish an instance of org.example.wa.MonthlySalary as the child of an instance of org.example.wa.Person after the child had already been persisted? Can anyone please suggest what's wrong with this program? -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.