在hiberate中些了个实体类bo,一般还要些一个相应的映射文件,把它映射到数据库中。但是像这样的bo大家见过吗?怎么回事?
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
@Entity
@Table(name = "tree", catalog = "tree")
public class Capacity extends RemovableBO implements OptimizationLockedBOStyleTwo {
// Fields
/**
*
*/
private static final long serialVersionUID = 2772774L;
private String capacityId;
private String driverLicence;
// Property accessors
@Id
@Column(name = "CAPACITY_ID", unique = true, nullable = false, length = 16)
public String getCapacityId() {
return this.capacityId;
}
public void setCapacityId(String capacityId) {
this.capacityId = capacityId;
}
@Column(name = "DRIVER_LICENCE", length = 64)
public String getDriverLicence() {
return driverLicence;
}
@Override
@Transient
public Serializable getEntityId() {
return this.getCapacityId();
}
}
[b]问题补充:[/b]
各位gg能讲的再详细点吗?谢谢/
自己看实例
http://www.blogjava.net/bolo/archive/2008/09/19/229823.html
http://developer.51cto.com/art/200909/154974.htm
jpa中使用的标注,不需要映射文件了
看ejb3的实体bean或者hibernate3.2的jpa就懂了
你都已经用了注解的方式,自然就不需要映射文件了
就是o/r mapping 把数据库表中的字段和你的实体类作了映射