Spring Boot 整合Spring Data JPA之Hibernate JPA(七)

本文主要介绍了Spring Boot如何整合Spring Data JPA,并重点探讨了Hibernate JPA的CRUD操作。首先解释了JPA作为Sun公司提供的持久层操作标准,以及Hibernate JPA作为其在Hibernate框架中的实现。随后,文章详细说明了在Spring Boot项目中引入Hibernate JPA的步骤,以及配置文件的设置。最后,简要介绍了进行基本的增删改查操作的方法。
摘要由CSDN通过智能技术生成

Spring Boot 整合Spring Data JPA之Hibernate JPA(七)

在spring boot整合spring data jpa之前先了解一下Hibernate JPA

JPA:由 Sun 公司提供了一对对于持久层操作的标准(接口+文档)
Hibernate:是 Gavin King 开发的一套对于持久层操作的自动的 ORM 框架。
Hibernate JPA:是在 Hibernate3.2 版本那种提供了对于 JPA 的标准的实现。提供了一套按
照 JPA 标准来实现持久层开发的 API
个人学习完之后到感觉:JPA其实不算是一套框架,更加像一套规则,或者是标准。

一、 Spring 整合 Hibernate JPA

在Hibernate项目中导入HIbernateJPA到jar包,这里我用但是web项目,不是maven项目。
在这里插入图片描述
配置xml到不同,Hibernate配置如下

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans.xsd
	http://www.springframework.org/schema/context
	http://www.springframework.org/schema/context/spring-context.xsd
	http://www.springframework.org/schema/aop
	http://www.springframework.org/schema/aop/spring-aop.xsd
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx.xsd">
	
	<!-- 配置读取properties文件的工具类 -->
	<context:property-placeholder location="classpath:jdbc.properties"/>
	
	<!-- 配置c3p0数据库连接池 -->
	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
		<property name="jdbcUrl" value="${jdbc.url}"/>
		<property name="driverClass" value="${jdbc.driver.class}"/>
		<property name="user" value="${jdbc.username}"/>
		<property name="password" value="${jdbc.password}"/>
	</bean>
	
	<!-- 配置Hibernate的SeesionFactory -->
	<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
		<property name="dataSource" ref="dataSource"/>
		<!-- hibernateProperties属性:配置与hibernate相关的内容,如显示sq
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

老徐··

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值