将 XML 数据导入 Google App Engine
2010-10-22 17:18:53 来源:WEB开发网清单 2 展示如何将这些元素表示为以下 POJO 类并使用 JDO 注释来注释它(这个注释类中假定适当的 Java 导入和一些 set 函数)。
清单 2. Employee.java
POJO Employee.java
Public class Employee {
private Long id;
private String firstName;
private String surName;
private String emailAddress;
private Date hireDate;
public Employee() {
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setSurName(String surName) {
this.surName = surName;
}
public void
setEmailAddress(String emailAddress) {
this.emailAddress = emailAddress;
}
public void setHireDate(Date hireDate) {
this.hireDate = hireDate;
}
public void setId(Long id) {
this.id = id;
}
}
Annotated Employee.java
@PersistenceCapable(identityType =
IdentityType.APPLICATION)
public class Employee {
@PrimaryKey
@Persistent(valueStrategy =
IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String firstName;
@Persistent
private String surName;
@Persistent
private String emailAddress;
@Persistent
private Date hireDate;
public Employee() {
}
}
赞助商链接