Created
August 12, 2012 01:46
-
-
Save agibsonccc/3328762 to your computer and use it in GitHub Desktop.
A sample spring hibernate 4 configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jdbc="http://www.springframework.org/schema/jdbc" | |
xmlns:context="http://www.springframework.org/schema/context" | |
xmlns:sec="http://www.springframework.org/schema/security" 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-3.1.xsd | |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd | |
http://www.springframework.org/schema/jdbc | |
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd"> | |
<!-- Component scanning --> | |
<bean id="testDao" class="org.agibsonccc.genericdao.TestDao" /> | |
<context:component-scan base-package="org.agibsonccc" /> | |
<context:annotation-config/> | |
<context:spring-configured/> | |
<!-- Properties files --> | |
<bean id="propertyPlaceHolderConfigurer" | |
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> | |
<property name="ignoreUnresolvablePlaceholders" value="true" /> | |
<property name="locations"> | |
<list> | |
<value>classpath:org/agibsonccc/genericdao/jpa.properties</value> | |
</list> | |
</property> | |
</bean> | |
<jdbc:embedded-database id="testdb" type="HSQL"> | |
<jdbc:script location="classpath:org/agibsonccc/genericdao/test.sql"/> | |
</jdbc:embedded-database> | |
<bean id="entityManagerFactory" | |
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> | |
<property name="dataSource" ref="dataSource" /> | |
<property name="packagesToScan" value="${jpa.packagescan}" /> | |
<property name="jpaVendorAdapter"> | |
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> | |
<property name="showSql" value="${hibernate.show_sql}" /> | |
<property name="generateDdl" value="${jpa.generateDdl}" /> | |
<property name="databasePlatform" value="${persistence.dialect}" /> | |
<property name="database" value="${database}"/> | |
</bean> | |
</property> | |
</bean> | |
<bean id="dataSource" | |
class="org.springframework.jdbc.datasource.DriverManagerDataSource"> | |
<property name="driverClassName" value="${jdbc.driver}" /> | |
<property name="url" value="${jdbc.url}" /> | |
<property name="username" value="${jdbc.user}" /> | |
<property name="password" value="${jdbc.password}" /> | |
</bean> | |
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> | |
<property name="entityManagerFactory" ref="entityManagerFactory" /> | |
</bean> | |
<tx:annotation-driven transaction-manager="transactionManager" /> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment