Hello everyone,
I have a class Employee (Parent) is MasterdData (Child).
The code of classes is at the end of the message.
When I try to write to the datastore:

Employee employee = new Employee ();
setMethod for employee use

MasterData masterData = new MasterData ();
method for use in September masterData istance

employee.setData (masterData);

PMF.get (). GetPersistenceManager (). MakePersistent (employe);

I get the error:
java.lang.IllegalStateException: Primary key for object of type
MasterData is null

Who helps me?
Thanks

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

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long ID;

    @Persistent
    private Key masterData;

    @Persistent
    private String name;

    private String lastName;

    @Persistent(mappedBy = "employee")
    private MasterData data;

    public Employee(String nome, String cognome, MasterData data) {
        this.name = nome;
        this.lastName = cognome;
        this.data = data;
    }
    public Long getID() {
        return ID;
    }
    public void setID(Long ID) {
        this.ID = ID;
    }
    public Key getMasterData() {
        return masterData;
    }
    public void setMasterData(Key masterData) {
        this.masterData = masterData;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getLastName() {
        return lastName;
    }
    public void setLastName(String lastName) {
        this.lastName = lastName;
    }
    public MasterData getData() {
        return data;
    }
    public void setData(MasterData data) {
        this.data = data;
    }
}


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

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

    @Persistent
    private Date dateOfBirth;

    @Persistent
    private String homeTown;

    @Persistent
    private String provinceTown;

    @Persistent
    private String cf;

    @Persistent
    private Employee employee;

    public MasterData(Date dateOfBirth, String homeTown, String
provinceTown, String cf) {
        this.dateOfBirth = dateOfBirth;
        this.homeTown = homeTown;
        this.provinceTown = provinceTown;
        this.cf = cf;
    }

    public Key getID() {
        return ID;
    }
    public void setID(Key ID) {
        this.ID = ID;
    }
    public Date getDateOfBirth() {
        return dateOfBirth;
    }
    public void setDateOfBirth(Date dateOfBirth) {
        this.dateOfBirth = dateOfBirth;
    }
    public String getHomeTown() {
        return homeTown;
    }
    public void setHomeTown(String homeTown) {
        this.homeTown = homeTown;
    }
    public String getProvinceTown() {
        return provinceTown;
    }
    public void setProvinceTown(String provinceTown) {
        this.provinceTown = provinceTown;
    }
    public String getCf() {
        return cf;
    }
    public void setCf(String cf) {
        this.cf = cf;
    }
    public Employee getEmployee() {
        return employee;
    }
    public void setEmployee(Employee employee) {
        this.employee = employee;
    }

}

public final class PMF {
    private static final PersistenceManagerFactory pmfInstance =
        JDOHelper.getPersistenceManagerFactory("transactions-
optional");

    private PMF() {}

    public static PersistenceManagerFactory get() {
        return pmfInstance;
    }
}



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