Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
541f3edd
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
541f3edd
编写于
3月 29, 2013
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fully upgraded orm.hibernate3 package to require Hibernate 3.6+ now
上级
e11cf5f0
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
20 addition
and
82 deletion
+20
-82
spring-orm/src/main/java/org/springframework/orm/hibernate3/FilterDefinitionFactoryBean.java
...framework/orm/hibernate3/FilterDefinitionFactoryBean.java
+1
-2
spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTransactionManager.java
...framework/orm/hibernate3/HibernateTransactionManager.java
+1
-1
spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalRegionFactoryProxy.java
...ringframework/orm/hibernate3/LocalRegionFactoryProxy.java
+2
-11
spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalSessionFactoryBean.java
...ringframework/orm/hibernate3/LocalSessionFactoryBean.java
+8
-21
spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java
...m/hibernate3/annotation/AnnotationSessionFactoryBean.java
+8
-47
未找到文件。
spring-orm/src/main/java/org/springframework/orm/hibernate3/FilterDefinitionFactoryBean.java
浏览文件 @
541f3edd
...
...
@@ -85,8 +85,7 @@ public class FilterDefinitionFactoryBean implements FactoryBean<FilterDefinition
/**
* Set the parameter types for the filter,
* with parameter names as keys and type names as values.
* See {@code org.hibernate.type.TypeFactory#heuristicType(String)} (Hibernate 3.x)
* or {@code org.hibernate.type.TypeResolver#heuristicType(String)} (Hibernate 4.x)
* See {@code org.hibernate.type.TypeResolver#heuristicType(String)}.
*/
public
void
setParameterTypes
(
Map
<
String
,
String
>
parameterTypes
)
{
if
(
parameterTypes
!=
null
)
{
...
...
spring-orm/src/main/java/org/springframework/orm/hibernate3/HibernateTransactionManager.java
浏览文件 @
541f3edd
...
...
@@ -110,7 +110,7 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
* support nested transactions! Hence, do not expect Hibernate access code to
* semantically participate in a nested transaction.</i>
*
* <p>Requires Hibernate 3.
2 or later, as of Spring 3
.0.
* <p>Requires Hibernate 3.
6 or later, as of Spring 4
.0.
*
* @author Juergen Hoeller
* @since 1.2
...
...
spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalRegionFactoryProxy.java
浏览文件 @
541f3edd
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -36,9 +36,6 @@ import org.springframework.util.ReflectionUtils;
* RegionFactory instance, determined by LocalSessionFactoryBean's
* "cacheRegionFactory" property.
*
* <p>Compatible with Hibernate 3.3 as well as Hibernate 3.5's version
* of the RegionFactory SPI.
*
* @author Juergen Hoeller
* @since 3.0
* @see LocalSessionFactoryBean#setCacheRegionFactory
...
...
@@ -83,13 +80,7 @@ public class LocalRegionFactoryProxy implements RegionFactory {
}
public
AccessType
getDefaultAccessType
()
{
try
{
Method
method
=
RegionFactory
.
class
.
getMethod
(
"getDefaultAccessType"
);
return
(
AccessType
)
ReflectionUtils
.
invokeMethod
(
method
,
this
.
regionFactory
);
}
catch
(
NoSuchMethodException
ex
)
{
throw
new
IllegalStateException
(
"getDefaultAccessType requires Hibernate 3.5+"
);
}
return
this
.
regionFactory
.
getDefaultAccessType
();
}
public
long
nextTimestamp
()
{
...
...
spring-orm/src/main/java/org/springframework/orm/hibernate3/LocalSessionFactoryBean.java
浏览文件 @
541f3edd
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
3
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.
...
...
@@ -18,7 +18,6 @@ package org.springframework.orm.hibernate3;
import
java.io.File
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Method
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
...
...
@@ -26,7 +25,6 @@ import java.util.Collection;
import
java.util.Enumeration
;
import
java.util.Map
;
import
java.util.Properties
;
import
javax.sql.DataSource
;
import
javax.transaction.TransactionManager
;
...
...
@@ -37,6 +35,7 @@ import org.hibernate.SessionFactory;
import
org.hibernate.cache.RegionFactory
;
import
org.hibernate.cfg.Configuration
;
import
org.hibernate.cfg.Environment
;
import
org.hibernate.cfg.Mappings
;
import
org.hibernate.cfg.NamingStrategy
;
import
org.hibernate.dialect.Dialect
;
import
org.hibernate.engine.FilterDefinition
;
...
...
@@ -44,6 +43,7 @@ import org.hibernate.engine.SessionFactoryImplementor;
import
org.hibernate.event.EventListeners
;
import
org.hibernate.tool.hbm2ddl.DatabaseMetadata
;
import
org.hibernate.transaction.JTATransactionFactory
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.BeanClassLoaderAware
;
import
org.springframework.core.io.ClassPathResource
;
...
...
@@ -53,7 +53,6 @@ import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy;
import
org.springframework.jdbc.support.JdbcUtils
;
import
org.springframework.jdbc.support.lob.LobHandler
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -89,7 +88,7 @@ import org.springframework.util.StringUtils;
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewFilter} /
* {@link org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor}.
*
* <p><b>Requires Hibernate 3.
2 or later; tested with 3.3, 3.5 and 3.6
.</b>
* <p><b>Requires Hibernate 3.
6 or later
.</b>
* Note that this factory will use "on_close" as default Hibernate connection
* release mode, unless in the case of a "jtaTransactionManager" specified,
* for the reason that this is appropriate for most Spring-based applications
...
...
@@ -583,15 +582,9 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
if
(
this
.
typeDefinitions
!=
null
)
{
// Register specified Hibernate type definitions.
// Use reflection for compatibility with both Hibernate 3.3 and 3.5:
// the returned Mappings object changed from a class to an interface.
Method
createMappings
=
Configuration
.
class
.
getMethod
(
"createMappings"
);
Method
addTypeDef
=
createMappings
.
getReturnType
().
getMethod
(
"addTypeDef"
,
String
.
class
,
String
.
class
,
Properties
.
class
);
Object
mappings
=
ReflectionUtils
.
invokeMethod
(
createMappings
,
config
);
Mappings
mappings
=
config
.
createMappings
();
for
(
TypeDefinitionBean
typeDef
:
this
.
typeDefinitions
)
{
ReflectionUtils
.
invokeMethod
(
addTypeDef
,
mappings
,
typeDef
.
getTypeName
(),
typeDef
.
getTypeClass
(),
typeDef
.
getParameters
());
mappings
.
addTypeDef
(
typeDef
.
getTypeName
(),
typeDef
.
getTypeClass
(),
typeDef
.
getParameters
());
}
}
...
...
@@ -628,8 +621,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
if
(
this
.
cacheRegionFactory
!=
null
)
{
// Expose Spring-provided Hibernate RegionFactory.
config
.
setProperty
(
Environment
.
CACHE_REGION_FACTORY
,
"org.springframework.orm.hibernate3.LocalRegionFactoryProxy"
);
config
.
setProperty
(
Environment
.
CACHE_REGION_FACTORY
,
LocalRegionFactoryProxy
.
class
.
getName
());
}
if
(
this
.
mappingResources
!=
null
)
{
...
...
@@ -685,12 +677,7 @@ public class LocalSessionFactoryBean extends AbstractSessionFactoryBean implemen
String
[]
strategyAndRegion
=
StringUtils
.
commaDelimitedListToStringArray
(
this
.
entityCacheStrategies
.
getProperty
(
className
));
if
(
strategyAndRegion
.
length
>
1
)
{
// method signature declares return type as Configuration on Hibernate 3.6
// but as void on Hibernate 3.3 and 3.5
Method
setCacheConcurrencyStrategy
=
Configuration
.
class
.
getMethod
(
"setCacheConcurrencyStrategy"
,
String
.
class
,
String
.
class
,
String
.
class
);
ReflectionUtils
.
invokeMethod
(
setCacheConcurrencyStrategy
,
config
,
className
,
strategyAndRegion
[
0
],
strategyAndRegion
[
1
]);
config
.
setCacheConcurrencyStrategy
(
className
,
strategyAndRegion
[
0
],
strategyAndRegion
[
1
]);
}
else
if
(
strategyAndRegion
.
length
>
0
)
{
config
.
setCacheConcurrencyStrategy
(
className
,
strategyAndRegion
[
0
]);
...
...
spring-orm/src/main/java/org/springframework/orm/hibernate3/annotation/AnnotationSessionFactoryBean.java
浏览文件 @
541f3edd
...
...
@@ -23,7 +23,6 @@ import javax.persistence.MappedSuperclass;
import
org.hibernate.HibernateException
;
import
org.hibernate.MappingException
;
import
org.hibernate.cfg.AnnotationConfiguration
;
import
org.hibernate.cfg.Configuration
;
import
org.springframework.context.ResourceLoaderAware
;
...
...
@@ -44,8 +43,8 @@ import org.springframework.util.ClassUtils;
* Subclass of Spring's standard LocalSessionFactoryBean for Hibernate,
* supporting JDK 1.5+ annotation metadata for mappings.
*
* <p>Note:
This class requires Hibernate 3.2 or later, with the
*
Java Persistence API and the Hibernate Annotations add-on
present.
* <p>Note:
As of Spring 4.0, this class requires Hibernate 3.6 or later,
*
with the Java Persistence API
present.
*
* <p>Example for an AnnotationSessionFactoryBean bean definition:
*
...
...
@@ -97,24 +96,10 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
private
ResourcePatternResolver
resourcePatternResolver
=
new
PathMatchingResourcePatternResolver
();
public
AnnotationSessionFactoryBean
()
{
setConfigurationClass
(
AnnotationConfiguration
.
class
);
}
@Override
public
void
setConfigurationClass
(
Class
<?>
configurationClass
)
{
if
(
configurationClass
==
null
||
!
AnnotationConfiguration
.
class
.
isAssignableFrom
(
configurationClass
))
{
throw
new
IllegalArgumentException
(
"AnnotationSessionFactoryBean only supports AnnotationConfiguration or subclasses"
);
}
super
.
setConfigurationClass
(
configurationClass
);
}
/**
* Specify annotated classes, for which mappings will be read from
* class-level JDK 1.5+ annotation metadata.
* @see org.hibernate.cfg.
Annotation
Configuration#addAnnotatedClass(Class)
* @see org.hibernate.cfg.Configuration#addAnnotatedClass(Class)
*/
public
void
setAnnotatedClasses
(
Class
[]
annotatedClasses
)
{
this
.
annotatedClasses
=
annotatedClasses
;
...
...
@@ -123,7 +108,7 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
/**
* Specify the names of annotated packages, for which package-level
* JDK 1.5+ annotation metadata will be read.
* @see org.hibernate.cfg.
Annotation
Configuration#addPackage(String)
* @see org.hibernate.cfg.Configuration#addPackage(String)
*/
public
void
setAnnotatedPackages
(
String
[]
annotatedPackages
)
{
this
.
annotatedPackages
=
annotatedPackages
;
...
...
@@ -163,25 +148,24 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
*/
@Override
protected
void
postProcessMappings
(
Configuration
config
)
throws
HibernateException
{
AnnotationConfiguration
annConfig
=
(
AnnotationConfiguration
)
config
;
if
(
this
.
annotatedClasses
!=
null
)
{
for
(
Class
annotatedClass
:
this
.
annotatedClasses
)
{
annC
onfig
.
addAnnotatedClass
(
annotatedClass
);
c
onfig
.
addAnnotatedClass
(
annotatedClass
);
}
}
if
(
this
.
annotatedPackages
!=
null
)
{
for
(
String
annotatedPackage
:
this
.
annotatedPackages
)
{
annC
onfig
.
addPackage
(
annotatedPackage
);
c
onfig
.
addPackage
(
annotatedPackage
);
}
}
scanPackages
(
annC
onfig
);
scanPackages
(
c
onfig
);
}
/**
* Perform Spring-based scanning for entity classes.
* @see #setPackagesToScan
*/
protected
void
scanPackages
(
Annotation
Configuration
config
)
{
protected
void
scanPackages
(
Configuration
config
)
{
if
(
this
.
packagesToScan
!=
null
)
{
try
{
for
(
String
pkg
:
this
.
packagesToScan
)
{
...
...
@@ -227,27 +211,4 @@ public class AnnotationSessionFactoryBean extends LocalSessionFactoryBean implem
return
false
;
}
/**
* This default implementation delegates to {@link #postProcessAnnotationConfiguration}.
*/
@Override
protected
void
postProcessConfiguration
(
Configuration
config
)
throws
HibernateException
{
postProcessAnnotationConfiguration
((
AnnotationConfiguration
)
config
);
}
/**
* To be implemented by subclasses which want to to perform custom
* post-processing of the AnnotationConfiguration object after this
* FactoryBean performed its default initialization.
* <p>Note: As of Hibernate 3.6, AnnotationConfiguration's features
* have been rolled into Configuration itself. Simply overriding
* {@link #postProcessConfiguration(org.hibernate.cfg.Configuration)}
* becomes an option as well then.
* @param config the current AnnotationConfiguration object
* @throws HibernateException in case of Hibernate initialization errors
*/
protected
void
postProcessAnnotationConfiguration
(
AnnotationConfiguration
config
)
throws
HibernateException
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录