– Start
除了通过 xml 的方式,我们还可以通过注解配置 ORM 映射。
package shangbo.hibernate.demo003;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
@Entity
@Table(name = "CUSTOMER")
public class Customer {
@Id
@Column(name = "CUSTOMER_ID")
@Type(type = "int")
private Integer customerId;
@Column(name = "CUSTOMER_NAME")
@Type(type = "string")
private String customerName;
public Customer() {
}
public Customer(Integer customerId, String customerName) {
this.customerId = customerId;
this.customerName = customerName;
}
public Integer getCustomerId() {
return customerId;
}
public void setCustomerId(Integer customerId) {
this.customerId = customerId;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
}
– 更多参见:Hibernate 精萃
– 声 明:转载请注明出处
– Last Updated on 2019-06-08
– Written by ShangBo on 2019-06-08
– End