提示:最近项目用到了JPA,就问问技术大牛郝哥JPA的教程有没有,大牛一看,反手给我了一个B站视频网址,快速入门JPA&SpringData整合教程入门到精通
我激动的立马点开链接,开始直接学习,但是没有老师的文档,十分的很难受。
做为资深的" B站白嫖党 ",我灵机一动,看看评论下面有没有资源,于是就发现有UP主的资料获取方法,
好家伙,我直呼内行,我就去加微信啊,加QQ群啊,发现客服小姐姐给的只有视频资料的百度云,但是没有文档,无奈之下,只能自力更生,顺便让后人乘凉!
【创建maven工程导入坐标】:
UTF-8 5.0.7.Final junit junit 4.12 test org.hibernate hibernate-entitymanager ${project.hibernate.version} org.hibernate hibernate-c3p0 ${project.hibernate.version} log4j log4j 1.2.17 mysql mysql-connector-java 5.1.32
创建JPA的核心配置:
1、meta-INF
2、persistence.xml
org.hibernate.jpa.HibernatePersistenceProvider
3、Customer.java
public class Customer {
private Long custId;
private String custName;
private String custSource;
private String custLevel;
private String custIndustry;
private String custPhone;
private String custAddress;
public Long getCustId() {
return custId;
}
public void setCustId(Long custId) {
this.custId = custId;
}
public String getCustName() {
return custName;
}
public void setCustName(String custName) {
this.custName = custName;
}
public String getCustSource() {
return custSource;
}
public void setCustSource(String custSource) {
this.custSource = custSource;
}
public String getCustLevel() {
return custLevel;
}
public void setCustLevel(String custLevel) {
this.custLevel = custLevel;
}
public String getCustIndustry() {
return custIndustry;
}
public void setCustIndustry(String custIndustry) {
this.custIndustry = custIndustry;
}
public String getCustPhone() {
return custPhone;
}
public void setCustPhone(String custPhone) {
this.custPhone = custPhone;
}
public String getCustAddress() {
return custAddress;
}
public void setCustAddress(String custAddress) {
this.custAddress = custAddress;
}
@Override
public String toString() {
return "Customer{" +
"custId=" + custId +
", custName='" + custName + ''' +
", custSource='" + custSource + ''' +
", custLevel='" + custLevel + ''' +
", custIndustry='" + custIndustry + ''' +
", custPhone='" + custPhone + ''' +
", custAddress='" + custAddress + ''' +
'}';
}
}



