I have an Employee class
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Employee {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;
@Persistent
private String firstName;
@Persistent
private String lastName;
@Persistent
private Date hireDate;
public Employee(String firstName, String lastName, Date hireDate) {
this.firstName = firstName;
this.lastName = lastName;
this.hireDate = hireDate;
}
// Accessors for the fields. JDO doesn't use these, but your application does.
public Key getKey() {
return key;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public Date getHireDate() {
return hireDate;
}
public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
}
}
I have used the JDO for the app engine. Now I want to share this code between server and client. In which package should I keep this. In fact I have tried both way. Neither worked out. Please share if you have already done this type of codes.
I've done this before, but just in a small test app. Assuming you're using GWT-RPC, it should work pretty smoothly. You'll have to do two things:
If you're not using GWT-RPC, you're on your own. JSON is attractive for this purpose but requires significant legwork. This should be better in GWT 2.0 but won't entirely go away.