WEB开发网
开发学院软件开发Java Google App Engine for Java,第 3 部分: 持久性和... 阅读

Google App Engine for Java,第 3 部分: 持久性和关系

 2009-09-17 00:00:00 来源:WEB开发网   
核心提示: 能够具有持久性,必须把它识别为一个具有 @PersistenceCapable注释的可持久性对象,Google App Engine for Java,第 3 部分: 持久性和关系(9),然后,需要对它所有的可持久性字段进行注释

能够具有持久性,必须把它识别为一个具有 @PersistenceCapable

注释的可持久性对象。然后,需要对它所有的可持久性字段进行注释,如清单 9 所示:

清单 9. Contact 具有可持久性

   
package gaej.example.contact.client; 
 
import java.io.Serializable; 
 
import javax.jdo.annotations.IdGeneratorStrategy; 
import javax.jdo.annotations.IdentityType; 
import javax.jdo.annotations.PersistenceCapable; 
import javax.jdo.annotations.Persistent; 
import javax.jdo.annotations.PrimaryKey; 
 
@PersistenceCapable(identityType = IdentityType.APPLICATION) 
public class Contact implements Serializable { 
 
 private static final long serialVersionUID = 1L; 
 @PrimaryKey 
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
 private Long id; 
 @Persistent 
 private String name; 
 @Persistent 
 private String email; 
 @Persistent 
 private String phone; 
 
 public Contact() { 
 
 } 
 
 public Contact(String name, String email, String phone) { 
 super(); 
 this.name = name; 
 this.email = email; 
 this.phone = phone; 
 } 
 
 public Long getId() { 
 return id; 
 } 
 
 public void setId(Long id) { 
 this.id = id; 
 } 
 
 public String getName() { 
 return name; 
 } 
 
 public void setName(String name) { 
 this.name = name; 
 } 
 
 public String getEmail() { 
 return email; 
 } 
 
 public void setEmail(String email) { 
 this.email = email; 
 } 
 
 public String getPhone() { 
 return phone; 
 } 
 
 public void setPhone(String phone) { 
 this.phone = phone; 
 } 
 
} 

上一页  4 5 6 7 8 9 10  下一页

Tags:Google App Engine

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接