Browse Source
Includes fix for consistent PersistenceException in case of no unit found for name. Includes proper tests for LocalContainerEntityManagerFactoryBean with scan setup. Closes gh-362726.2.x
17 changed files with 157 additions and 17 deletions
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright 2002-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.orm.jpa.eclipselink; |
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
class EclipseLinkEntityManagerFactoryScanIntegrationTests extends EclipseLinkEntityManagerFactoryIntegrationTests { |
||||
|
||||
@Override |
||||
protected String[] getConfigLocations() { |
||||
return new String[] {"/org/springframework/orm/jpa/eclipselink/eclipselink-manager-scan.xml", |
||||
"/org/springframework/orm/jpa/memdb.xml", "/org/springframework/orm/jpa/inject.xml"}; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,30 @@
@@ -0,0 +1,30 @@
|
||||
/* |
||||
* Copyright 2002-present the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package org.springframework.orm.jpa.hibernate; |
||||
|
||||
/** |
||||
* @author Juergen Hoeller |
||||
*/ |
||||
class HibernateEntityManagerFactoryScanIntegrationTests extends HibernateEntityManagerFactoryIntegrationTests { |
||||
|
||||
@Override |
||||
protected String[] getConfigLocations() { |
||||
return new String[] {"/org/springframework/orm/jpa/hibernate/hibernate-manager-scan.xml", |
||||
"/org/springframework/orm/jpa/memdb.xml", "/org/springframework/orm/jpa/inject.xml"}; |
||||
} |
||||
|
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> |
||||
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> |
||||
<property name="persistenceUnitName" value="Person"/> |
||||
<property name="packagesToScan" value="org.springframework.orm.jpa.domain*"/> |
||||
<property name="dataSource" ref="dataSource"/> |
||||
<property name="jpaVendorAdapter"> |
||||
<bean class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter"> |
||||
<property name="database" value="HSQL"/> |
||||
<property name="showSql" value="true"/> |
||||
<property name="generateDdl" value="true"/> |
||||
</bean> |
||||
</property> |
||||
<property name="jpaPropertyMap"> |
||||
<props> |
||||
<prop key="eclipselink.weaving">false</prop> |
||||
</props> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/> |
||||
</bean> |
||||
|
||||
</beans> |
||||
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<beans xmlns="http://www.springframework.org/schema/beans" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> |
||||
|
||||
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" primary="true"> |
||||
<property name="persistenceUnitName" value="Person"/> |
||||
<property name="packagesToScan" value="org.springframework.orm.jpa.domain*"/> |
||||
<property name="dataSource" ref="dataSource"/> |
||||
<property name="jpaVendorAdapter"> |
||||
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> |
||||
<property name="database" value="HSQL"/> |
||||
<property name="showSql" value="true"/> |
||||
<property name="generateDdl" value="true"/> |
||||
</bean> |
||||
</property> |
||||
<property name="jpaPropertyMap"> |
||||
<props> |
||||
<prop key="hibernate.current_session_context_class">org.springframework.orm.jpa.hibernate.SpringSessionContext</prop> |
||||
<prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop> |
||||
</props> |
||||
</property> |
||||
<property name="bootstrapExecutor"> |
||||
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"/> |
||||
</property> |
||||
</bean> |
||||
|
||||
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> |
||||
<property name="entityManagerFactory" ref="entityManagerFactory"/> |
||||
</bean> |
||||
|
||||
<bean id="hibernateStatistics" factory-bean="entityManagerFactory" factory-method="getStatistics" lazy-init="true"/> |
||||
|
||||
<bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator"/> |
||||
|
||||
</beans> |
||||
Loading…
Reference in new issue