WEB开发网
开发学院软件开发Java Java 开发 2.0: 使用 Google App Engine 阅读

Java 开发 2.0: 使用 Google App Engine

 2009-09-09 00:00:00 来源:WEB开发网   
核心提示: 清单 3. 为 triathlon JDO 添加一个主键importjava.util.Date;importjavax.jdo.annotations.IdGeneratorStrategy;importjavax.jdo.annotations.PersistenceCapable;impo

清单 3. 为 triathlon JDO 添加一个主键

   
import java.util.Date; 
import javax.jdo.annotations.IdGeneratorStrategy; 
import javax.jdo.annotations.PersistenceCapable; 
import javax.jdo.annotations.Persistent; 
import javax.jdo.annotations.PrimaryKey; 
import javax.jdo.annotations.IdentityType; 
import org.apache.commons.lang.builder.EqualsBuilder; 
import org.apache.commons.lang.builder.HashCodeBuilder; 
import org.apache.commons.lang.builder.ReflectionToStringBuilder; 
 
@PersistenceCapable(identityType = IdentityType.APPLICATION) 
public class Triathlon { 
 @PrimaryKey 
 @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) 
 private Long id; 
 
 @Persistent 
 private Date date; 
 
 @Persistent 
 private String name; 
 
 @Persistent 
 private String description; 
 
 public Triathlon(Date date, String name, String description) { 
 super(); 
 this.date = date; 
 this.name = name; 
 this.description = description; 
 } 
 
 //...setters and getters left out 
 
 public String toString() { 
 return ReflectionToStringBuilder.toString(this); 
 } 
 
 public int hashCode() { 
 return HashCodeBuilder.reflectionHashCode(this); 
 } 
 
 public boolean equals(Object obj) { 
 return EqualsBuilder.reflectionEquals(this, obj); 
 } 
} 

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

Tags:Java 开发 使用

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