这里使用的是mysql数据库,导入以下hubernate和mysql的架包
1、编写一个实体类(持久化类):Book.java
package com.pojo;
public class Book {
private Integer id; // 主键
private String bookName;
private String author;
private Double price;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getBookName() {
return bookName;
}
public void setBookName(String bookName) {
this.bookName = bookName;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}
2、编写映射文件:Book.hbm.xml
<?xml version="1.0" encoding="UTF-8&