您是否擁有Hibernate實體的公共基類,即具有id,版本和其他常用屬性的MappedSuperclass?有什麼缺點嗎?你有一個Hibernate實體的公共基類嗎?
例子:
@MappedSuperclass()
public class BaseEntity {
private Long id;
private Long version;
...
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {return id;}
public void setId(Long id) {this.id = id;}
@Version
public Long getVersion() {return version;}
...
// Common properties
@Temporal(TemporalType.TIMESTAMP)
public Date creationDate() {return creationDate;}
...
}
@Entity
public class Customer extends BaseEntity {
private String customerName;
...
}
對不起,你爲什麼要使用一個while循環什麼似乎更適合在一個for循環? – 2009-01-29 15:42:54