ssh(sturts2_spring_hibernate) 框架搭建之JPA代替hibernate
一、JPA用来替代hibernate ⒈JPA的全称是JAVA Persistence API。指的是JPA通过注解或者是XML描述对象—关系表的映射关系,并且将运行的实体对象持久化数据库中。 ⒉JPA是一种规范,hibernate是一种实现。同样的mybatis也是jpa中的一种实现。 二、构建步骤: ⒈创建persistence.xml文件: ⑴、首先在你的项目中的src目录下新建一个MATA-INF文件夹,文件夹的名字不可以是任意,必须是MATA-INF: ⑵、新建一个xml文件,命名为persistence.xml: ⑶、接下来,在persistence.xml文件中进行相关的配置,如下: <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1