X Tutup
Skip to content

Commit ceb9a05

Browse files
committed
General JPA 2.0+ requirement; upgraded build and tests to EclipseLink 2.4, OpenJPA 2.2, Hibernate 3.6
1 parent 90f79f3 commit ceb9a05

29 files changed

+86
-760
lines changed

build.gradle

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ project("spring-context") {
305305
optional("javax.ejb:ejb-api:3.0")
306306
optional("javax.inject:javax.inject:1")
307307
optional("org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1")
308-
optional("javax.persistence:persistence-api:1.0")
308+
optional("org.eclipse.persistence:javax.persistence:2.0.0")
309309
optional("javax.validation:validation-api:1.0.0.GA")
310310
optional("org.beanshell:bsh:2.0b4")
311311
optional("org.codehaus.groovy:groovy-all:1.8.8")
@@ -336,7 +336,7 @@ project("spring-tx") {
336336
optional("javax.resource:connector-api:1.5")
337337
optional("org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1")
338338
optional("javax.ejb:ejb-api:3.0")
339-
testCompile("javax.persistence:persistence-api:1.0")
339+
testCompile("org.eclipse.persistence:javax.persistence:2.0.0")
340340
testCompile("org.aspectj:aspectjweaver:${aspectjVersion}")
341341
}
342342
}
@@ -478,31 +478,19 @@ project("spring-web") {
478478
project("spring-orm") {
479479
description = "Spring Object/Relational Mapping"
480480

481-
compileTestJava {
482-
// necessary to avoid java.lang.VerifyError on toplink compilation
483-
// TODO: remove this block when we remove toplink
484-
sourceCompatibility=1.6
485-
targetCompatibility=1.6
486-
}
487-
488481
dependencies {
489482
compile("aopalliance:aopalliance:1.0")
490-
optional("org.hibernate:hibernate-core:3.3.2.GA")
491-
optional("org.hibernate:hibernate-annotations:3.4.0.GA")
492-
optional("org.hibernate:hibernate-entitymanager:3.4.0.GA")
493-
optional("org.apache.openjpa:openjpa:1.1.0")
494-
optional("org.eclipse.persistence:org.eclipse.persistence.core:1.0.1")
495-
optional("org.eclipse.persistence:org.eclipse.persistence.jpa:1.0.1")
496-
optional("toplink.essentials:toplink-essentials:2.0-41b")
483+
optional("org.eclipse.persistence:javax.persistence:2.0.0")
484+
optional("org.eclipse.persistence:org.eclipse.persistence.core:2.4.0")
485+
optional("org.eclipse.persistence:org.eclipse.persistence.jpa:2.4.0")
486+
optional("org.hibernate:hibernate-core:3.6.9.Final")
487+
optional("org.hibernate:hibernate-entitymanager:3.6.9.Final")
488+
optional("org.apache.openjpa:openjpa:2.2.1")
497489
optional("javax.jdo:jdo-api:3.0")
498-
optional("org.apache.ibatis:ibatis-sqlmap:2.3.4.726")
499-
optional("javax.persistence:persistence-api:1.0")
500490
provided("javax.servlet:servlet-api:2.5")
501491
testCompile("javax.servlet:javax.servlet-api:3.0.1")
502492
testCompile("org.slf4j:slf4j-jcl:${slf4jVersion}")
503493
testCompile("commons-dbcp:commons-dbcp:1.2.2")
504-
testCompile("org.eclipse.persistence:org.eclipse.persistence.asm:1.0.1")
505-
testCompile("org.eclipse.persistence:org.eclipse.persistence.antlr:1.0.1")
506494
testCompile("hsqldb:hsqldb:${hsqldbVersion}")
507495
compile(project(":spring-core"))
508496
compile(project(":spring-beans"))
@@ -520,8 +508,8 @@ project("spring-orm-hibernate4") {
520508
dependencies {
521509
provided(project(":spring-tx"))
522510
provided(project(":spring-jdbc"))
523-
optional("org.hibernate:hibernate-core:4.1.0.Final")
524-
optional("org.hibernate:hibernate-entitymanager:4.1.0.Final")
511+
optional("org.hibernate:hibernate-core:4.1.9.Final")
512+
optional("org.hibernate:hibernate-entitymanager:4.1.9.Final")
525513
optional(project(":spring-web"))
526514
optional("javax.servlet:servlet-api:2.5")
527515
}
@@ -666,9 +654,9 @@ project("spring-test") {
666654
optional("javax.servlet:servlet-api:2.5")
667655
optional("javax.servlet.jsp:jsp-api:2.1")
668656
optional("javax.portlet:portlet-api:2.0")
669-
optional("javax.persistence:persistence-api:1.0")
657+
optional("org.eclipse.persistence:javax.persistence:2.0.0")
670658
optional("org.aspectj:aspectjweaver:${aspectjVersion}")
671-
testCompile("org.hibernate:hibernate-core:3.3.2.GA")
659+
testCompile("org.hibernate:hibernate-core:3.6.9.Final")
672660
provided("javax.inject:javax.inject:1")
673661
provided("javax.activation:activation:1.1")
674662
provided("javax.servlet:jstl:1.2")
@@ -738,7 +726,7 @@ project("spring-aspects") {
738726
optional(project(":spring-tx")) // for JPA, @Transactional support
739727
optional(project(":spring-orm")) // for JPA exception translation support
740728
aspects(project(":spring-orm"))
741-
provided("javax.persistence:persistence-api:1.0")
729+
provided("org.eclipse.persistence:javax.persistence:2.0.0")
742730
testCompile("javax.mail:mail:1.4")
743731
ajc("org.aspectj:aspectjtools:${aspectjVersion}")
744732
rt("org.aspectj:aspectjrt:${aspectjVersion}")
@@ -786,7 +774,7 @@ configure(rootProject) {
786774
testCompile(project(":spring-web"))
787775
testCompile(project(":spring-webmvc-portlet"))
788776
testCompile(project(":spring-orm"))
789-
testCompile("org.hibernate:hibernate-core:4.1.0.Final")
777+
testCompile("org.hibernate:hibernate-core:4.1.9.Final")
790778
testCompile("javax.servlet:servlet-api:2.5")
791779
testCompile("javax.portlet:portlet-api:2.0")
792780
testCompile("javax.inject:javax.inject:1")

spring-orm/src/main/java/org/springframework/orm/hibernate3/FilterDefinitionFactoryBean.java

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2013 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,18 +16,16 @@
1616

1717
package org.springframework.orm.hibernate3;
1818

19-
import java.lang.reflect.Method;
2019
import java.util.HashMap;
2120
import java.util.Map;
2221

2322
import org.hibernate.engine.FilterDefinition;
2423
import org.hibernate.type.Type;
25-
import org.hibernate.type.TypeFactory;
24+
import org.hibernate.type.TypeResolver;
2625

2726
import org.springframework.beans.factory.BeanNameAware;
2827
import org.springframework.beans.factory.FactoryBean;
2928
import org.springframework.beans.factory.InitializingBean;
30-
import org.springframework.util.ReflectionUtils;
3129

3230
/**
3331
* Convenient FactoryBean for defining Hibernate FilterDefinitions.
@@ -66,29 +64,7 @@
6664
*/
6765
public class FilterDefinitionFactoryBean implements FactoryBean<FilterDefinition>, BeanNameAware, InitializingBean {
6866

69-
private static Method heuristicTypeMethod;
70-
71-
private static Object typeResolver;
72-
73-
static {
74-
// Hibernate 3.6 TypeResolver class available?
75-
try {
76-
Class<?> trClass = FilterDefinitionFactoryBean.class.getClassLoader().loadClass(
77-
"org.hibernate.type.TypeResolver");
78-
heuristicTypeMethod = trClass.getMethod("heuristicType", String.class);
79-
typeResolver = trClass.newInstance();
80-
}
81-
catch (Exception ex) {
82-
try {
83-
heuristicTypeMethod = TypeFactory.class.getMethod("heuristicType", String.class);
84-
typeResolver = null;
85-
}
86-
catch (Exception ex2) {
87-
throw new IllegalStateException("Cannot find Hibernate's heuristicType method", ex2);
88-
}
89-
}
90-
}
91-
67+
private final TypeResolver typeResolver = new TypeResolver();
9268

9369
private String filterName;
9470

@@ -116,8 +92,7 @@ public void setParameterTypes(Map<String, String> parameterTypes) {
11692
if (parameterTypes != null) {
11793
this.parameterTypeMap = new HashMap<String, Type>(parameterTypes.size());
11894
for (Map.Entry<String, String> entry : parameterTypes.entrySet()) {
119-
this.parameterTypeMap.put(entry.getKey(),
120-
(Type) ReflectionUtils.invokeMethod(heuristicTypeMethod, typeResolver, entry.getValue()));
95+
this.parameterTypeMap.put(entry.getKey(), this.typeResolver.heuristicType(entry.getValue()));
12196
}
12297
}
12398
else {

spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalCacheProviderProxy.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalSessionFactoryBean.java

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.hibernate.Interceptor;
3535
import org.hibernate.Session;
3636
import org.hibernate.SessionFactory;
37+
import org.hibernate.cache.RegionFactory;
3738
import org.hibernate.cfg.Configuration;
3839
import org.hibernate.cfg.Environment;
3940
import org.hibernate.cfg.NamingStrategy;
@@ -159,19 +160,6 @@ static Object getConfigTimeRegionFactory() {
159160
return configTimeRegionFactoryHolder.get();
160161
}
161162

162-
/**
163-
* Return the CacheProvider for the currently configured Hibernate SessionFactory,
164-
* to be used by LocalCacheProviderProxy.
165-
* <p>This instance will be set before initialization of the corresponding
166-
* SessionFactory, and reset immediately afterwards. It is thus only available
167-
* during configuration.
168-
* @see #setCacheProvider
169-
*/
170-
@SuppressWarnings("deprecation")
171-
public static org.hibernate.cache.CacheProvider getConfigTimeCacheProvider() {
172-
return configTimeCacheProviderHolder.get();
173-
}
174-
175163
/**
176164
* Return the LobHandler for the currently configured Hibernate SessionFactory,
177165
* to be used by UserType implementations like ClobStringType.
@@ -206,10 +194,7 @@ public static LobHandler getConfigTimeLobHandler() {
206194

207195
private TransactionManager jtaTransactionManager;
208196

209-
private Object cacheRegionFactory;
210-
211-
@SuppressWarnings("deprecation")
212-
private org.hibernate.cache.CacheProvider cacheProvider;
197+
private RegionFactory cacheRegionFactory;
213198

214199
private LobHandler lobHandler;
215200

@@ -381,32 +366,14 @@ public void setJtaTransactionManager(TransactionManager jtaTransactionManager) {
381366
/**
382367
* Set the Hibernate RegionFactory to use for the SessionFactory.
383368
* Allows for using a Spring-managed RegionFactory instance.
384-
* <p>As of Hibernate 3.3, this is the preferred mechanism for configuring
385-
* caches, superseding the {@link #setCacheProvider CacheProvider SPI}.
386-
* For Hibernate 3.2 compatibility purposes, the accepted reference is of type
387-
* Object: the actual type is {@code org.hibernate.cache.RegionFactory}.
388369
* <p>Note: If this is set, the Hibernate settings should not define a
389370
* cache provider to avoid meaningless double configuration.
390371
* @see org.hibernate.cache.RegionFactory
391372
*/
392-
public void setCacheRegionFactory(Object cacheRegionFactory) {
373+
public void setCacheRegionFactory(RegionFactory cacheRegionFactory) {
393374
this.cacheRegionFactory = cacheRegionFactory;
394375
}
395376

396-
/**
397-
* Set the Hibernate CacheProvider to use for the SessionFactory.
398-
* Allows for using a Spring-managed CacheProvider instance.
399-
* <p>Note: If this is set, the Hibernate settings should not define a
400-
* cache provider to avoid meaningless double configuration.
401-
* @deprecated as of Spring 3.0, following Hibernate 3.3's deprecation
402-
* of the CacheProvider SPI
403-
* @see #setCacheRegionFactory
404-
*/
405-
@Deprecated
406-
public void setCacheProvider(org.hibernate.cache.CacheProvider cacheProvider) {
407-
this.cacheProvider = cacheProvider;
408-
}
409-
410377
/**
411378
* Set the LobHandler to be used by the SessionFactory.
412379
* Will be exposed at config time for UserType implementations.
@@ -564,10 +531,6 @@ protected SessionFactory buildSessionFactory() throws Exception {
564531
// Make Spring-provided Hibernate RegionFactory available.
565532
configTimeRegionFactoryHolder.set(this.cacheRegionFactory);
566533
}
567-
if (this.cacheProvider != null) {
568-
// Make Spring-provided Hibernate CacheProvider available.
569-
configTimeCacheProviderHolder.set(this.cacheProvider);
570-
}
571534
if (this.lobHandler != null) {
572535
// Make given LobHandler available for SessionFactory configuration.
573536
// Do early because because mapping resource might refer to custom types.
@@ -668,10 +631,6 @@ else if (config.getProperty(Environment.TRANSACTION_MANAGER_STRATEGY) != null) {
668631
config.setProperty(Environment.CACHE_REGION_FACTORY,
669632
"org.springframework.orm.hibernate3.LocalRegionFactoryProxy");
670633
}
671-
else if (this.cacheProvider != null) {
672-
// Expose Spring-provided Hibernate CacheProvider.
673-
config.setProperty(Environment.CACHE_PROVIDER, LocalCacheProviderProxy.class.getName());
674-
}
675634

676635
if (this.mappingResources != null) {
677636
// Register given Hibernate mapping definitions, contained in resource files.
@@ -792,9 +751,6 @@ else if (strategyAndRegion.length > 0) {
792751
if (this.cacheRegionFactory != null) {
793752
configTimeRegionFactoryHolder.remove();
794753
}
795-
if (this.cacheProvider != null) {
796-
configTimeCacheProviderHolder.remove();
797-
}
798754
if (this.lobHandler != null) {
799755
configTimeLobHandlerHolder.remove();
800756
}

0 commit comments

Comments
 (0)
X Tutup