Spring+jpa+access
========访问数据库的属于文件============
driver=com.hxtt.sql.access.AccessDriver
url=jdbc:access:/D:/eclipse/project/jee/workspace/jubweb2/src/message.mdb
dialect=org.hibernate.dialect.SQLServerDialect
path=D:/eclipse/project/jee/workspace/jubweb2/src/message.mdb
uname=
pwd=
==========application.xml=====================
<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
">
<context:property-placeholder location="classpath:/META-INF/db.Properties" /><!--连接数据库的属性文件的路径-->
<!-- 把标记了@Controller注解的类转换为bean-->
<context:component-scan base-package="com.jubangit.jubweb2.*" />
<mvc:annotation-driven />
<!--解决web.xml拦截非action路径的问题-->
<mvc:default-servlet-handler/>
<!--spring管理拦截器 -->
<!-- <mvc:interceptors>
<bean class="com.jb.tool.JToolSystemInterceptor" />
</mvc:interceptors> -->
<!-- 定义跳转的文件的前后缀 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- <property name="prefix" value="/WEB-INF/jsp/" /> --> <!-- jsp存放的路径-->
<property name="suffix" value=".jsp" /> <!-- 指定跳转的页面为.jsp格式 -->
</bean>
<!--事物托管-->
<!-- JPA Entity Manager Factory -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" p:dataSource-ref="dataSource">
<property name="packagesToScan" value="com.jubangit.jubweb2.entity"/> <!--如果删除了persistence.xml,则需要指定实体所在的路径否则会报找不到该文件-->
<property name="jpaDialect">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaDialect" />
</property>
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
<property name="persistenceProvider">
<bean class="org.hibernate.ejb.HibernatePersistence"/><!-- 用于指定持久化实现厂商类 -->
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.dialect">${dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.max_fetch_depth">3</prop>
<prop key="hibernate.jdbc.fetch_size">18</prop>
<prop key="hibernate.jdbc.batch_size">10</prop>
<!-- <prop key="hibernate.hbm2ddl.auto">create</prop> --><!-- 定义是否自动生成表,create表示每次加载都重新生成,update表示每次加载只是更新表 -->
</props>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"><!--dbcp连接池-->
<property name="driverClassName"><value>${driver}</value></property>
<property name="url"><value>${url}</value></property>
<property name="username"><value>${uname}</value></property>
<property name="password"><value>${pwd}</value></property>
<property name="initialSize"><value>5</value></property>
<property name="maxActive"><value>50</value></property>
<property name="maxIdle"><value>10</value></property>
<property name="minIdle"><value>5</value></property>
<property name="connectionProperties" value="charSet=gbk;"></property><!-- 解决UTF8编码连接读取Access数据库乱码问题 -->
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- 事物通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="sav*" propagation="REQUIRED" rollback-for="Exception"/> <!-- rollback-for回滚事物,果存在一个事务,则支持当前事务。如果没有事务则开启 -->
<tx:method name="del*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="updat*" propagation="REQUIRED" rollback-for="Exception"/>
<tx:method name="qry*" propagation="NOT_SUPPORTED" read-only="true"/>
<tx:method name="*" propagation="NOT_SUPPORTED" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 事物切入 -->
<aop:config>
<aop:pointcut id="cut"
expression="execution(* com.jubangit.jubweb2.services.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="cut" />
</aop:config>
</beans>
Spring+jpa+access的更多相关文章
- Spring JPA事务
目录 1. 概述 促进阅读: 2. 配置不带XML的事务 3. 使用XML配置事务 4. @Transactional 注解 5. 潜在的陷阱 5.1. 事务和代理 5.2. 更改隔离级别 5.3. ...
- spring jpa 实体互相引用返回restful数据循环引用报错的问题
spring jpa 实体互相引用返回restful数据循环引用报错的问题 Java实体里两个对象有关联关系,互相引用,比如,在一对多的关联关系里 Problem对象,引用了标签列表ProblemLa ...
- spring jpa 自定义查询数据库的某个字段
spring jpa 提供的查询很强大, 就看你会不会用了. 先上代码, 后面在解释吧 1. 想查单个表的某个字段 在repository中 @Query(value = "select i ...
- Hibernate | Spring JPA | MySQL 使用过程遇到的一些问题
1. 使用过程 2. 背景 3. 遇到问题 3.1 不指定Hibernate数据库方言,默认SQL生成方式 3.2 抛出异常Hibernate加入了@Transactional事务不会回滚 3.3 H ...
- Spring JPA 使用@CreatedDate、@CreatedBy、@LastModifiedDate、@LastModifiedBy 自动生成时间和修改者
JPA Audit 在spring jpa中,支持在字段或者方法上进行注解@CreatedDate.@CreatedBy.@LastModifiedDate.@LastModifiedBy,从字面意思 ...
- Spring JPA学习笔记
目录 什么是JPA? 引入配置 新建一个Entity Bean类 JPA的增删改查 新建操作接口 新建测试类 总结 什么是JPA? 什么是JDBC知道吧?数据库有Mysql,SQL Server,Or ...
- Spring JPA实现逻辑源码分析总结
1.SharedEntityManagerCreator: entitymanager的创建入口 该类被EntityManagerBeanDefinitionRegistrarPostProcesso ...
- 使用Spring JPA中Page、Pageable接口和Sort类完成分页排序
显示时,有三个参数,前两个必填,第几页,一页多少个size,第三个参数默认可以不填. 但是发现这个方法已经过时了,通过查看它的源码发现,新方法为静态方法PageRequest of(page,size ...
- spring jpa和mybatis整合
spring jpa和mybatis整合 前一阵子接手了一个使用SpringBoot 和spring-data-jpa开发的项目 后期新加入一个小伙伴,表示jpa相比mybatis太难用,多表联合的查 ...
随机推荐
- 长期演进技术(LTE,Long Term Evolution)
/********************************************************************************* * 长期演进技术(LTE,Long ...
- RequireJS入门指导 (转)
最近在百度实习做的一个项目用到了 Require JS 这个库,之前从来没有了解过,经过一番大概的搜索后找到一篇非常不错的文章,看完后能够让你对 Require JS 的运行机制.使用方法以及为什么使 ...
- RandomAcessFile、MappedByteBuffer和缓冲读/写文件
项目需要进行大文件的读写,调查测试的结果使我决定使用MappedByteBuffer及相关类进行文件的操作,效果不是一般的高. 网上参考资源很多,如下两篇非常不错: 1.花1K内存实现高效I/O的Ra ...
- 使用Spring MVC统一异常处理实战
1 描述 在J2EE项目的开发中,不管是对底层的数据库操作过程,还是业务层的处理过程,还是控制层的处理过程,都不可避免会遇到各种可预知的.不可预知的异常需要处理.每个过程都单独处理异常,系统的代码耦合 ...
- Downloading the Source
The Android source tree is located in a Git repository hosted by Google. This document describes ho ...
- Java多线程的五种状态
新建状态:new Thread(参数)之后,建立了一个线程对象; 就绪状态:线程对象建立之后,调用start()方法,进入就绪状态,此时并不会直接调用run()方法,线程进入运行状态还需要抢占CPU资 ...
- python3 多线程的基本用法
#coding=utf-8 import threading #导入threading包 from time import sleep import time def task1(): p ...
- 高薪诚聘.NET MVC开发工程师
你想有大好的发展前途吗?你想拥有高的月薪吗? 赶快来吧! 1.企业网站.电子商务开发: 2.进行详细设计.代码开发,配合测试,高质量完成项目: 3.参与技术难题攻关.组织技术积累等工作. 任职资格: ...
- bzoj 2190 [SDOI2008]仪仗队(欧拉函数)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2190 [题意] n*n的正方形,在(0,0)格点可以看到的格子数目. [思路] 预处理 ...
- 黑马程序员——Foundation之NSString和NSMutableString
------Java培训.Android培训.iOS培训.Net培训.期待与您交流!------ 在OC中NSString是一个非常重要的字符串类;和C语言的字符串不用的是,C语言的字符串是用双引号括 ...