Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
19e5a34f
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,体验更适合开发者的 AI 搜索 >>
提交
19e5a34f
编写于
7月 06, 2016
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Restored binary compatibility with Hibernate 5.0/5.1's Query type
Issue: SPR-14425
上级
5890758f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
25 addition
and
5 deletion
+25
-5
spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
...org/springframework/orm/hibernate5/HibernateTemplate.java
+25
-5
未找到文件。
spring-orm/src/main/java/org/springframework/orm/hibernate5/HibernateTemplate.java
浏览文件 @
19e5a34f
...
@@ -45,6 +45,7 @@ import org.springframework.dao.DataAccessException;
...
@@ -45,6 +45,7 @@ import org.springframework.dao.DataAccessException;
import
org.springframework.dao.InvalidDataAccessApiUsageException
;
import
org.springframework.dao.InvalidDataAccessApiUsageException
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ReflectionUtils
;
/**
/**
* Helper class that simplifies Hibernate data access code. Automatically
* Helper class that simplifies Hibernate data access code. Automatically
...
@@ -83,6 +84,20 @@ import org.springframework.util.Assert;
...
@@ -83,6 +84,20 @@ import org.springframework.util.Assert;
*/
*/
public
class
HibernateTemplate
implements
HibernateOperations
,
InitializingBean
{
public
class
HibernateTemplate
implements
HibernateOperations
,
InitializingBean
{
private
static
final
Method
createQueryMethod
;
static
{
// Hibernate 5.2's createQuery method declares a new subtype as return type,
// so we need to use reflection for binary compatibility with 5.0/5.1 here.
try
{
createQueryMethod
=
Session
.
class
.
getMethod
(
"createQuery"
,
String
.
class
);
}
catch
(
NoSuchMethodException
ex
)
{
throw
new
IllegalStateException
(
"Incompatible Hibernate Session API"
,
ex
);
}
}
protected
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
protected
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
private
SessionFactory
sessionFactory
;
private
SessionFactory
sessionFactory
;
...
@@ -863,7 +878,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
...
@@ -863,7 +878,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Override
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
org
.
hibernate
.
Query
queryObject
=
session
.
createQuery
(
queryString
);
org
.
hibernate
.
Query
queryObject
=
(
org
.
hibernate
.
Query
)
ReflectionUtils
.
invokeMethod
(
createQueryMethod
,
session
,
queryString
);
prepareQuery
(
queryObject
);
prepareQuery
(
queryObject
);
if
(
values
!=
null
)
{
if
(
values
!=
null
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
...
@@ -893,7 +909,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
...
@@ -893,7 +909,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Override
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
org
.
hibernate
.
Query
queryObject
=
session
.
createQuery
(
queryString
);
org
.
hibernate
.
Query
queryObject
=
(
org
.
hibernate
.
Query
)
ReflectionUtils
.
invokeMethod
(
createQueryMethod
,
session
,
queryString
);
prepareQuery
(
queryObject
);
prepareQuery
(
queryObject
);
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
applyNamedParameterToQuery
(
queryObject
,
paramNames
[
i
],
values
[
i
]);
applyNamedParameterToQuery
(
queryObject
,
paramNames
[
i
],
values
[
i
]);
...
@@ -911,7 +928,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
...
@@ -911,7 +928,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Override
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
public
List
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
org
.
hibernate
.
Query
queryObject
=
session
.
createQuery
(
queryString
);
org
.
hibernate
.
Query
queryObject
=
(
org
.
hibernate
.
Query
)
ReflectionUtils
.
invokeMethod
(
createQueryMethod
,
session
,
queryString
);
prepareQuery
(
queryObject
);
prepareQuery
(
queryObject
);
queryObject
.
setProperties
(
valueBean
);
queryObject
.
setProperties
(
valueBean
);
return
queryObject
.
list
();
return
queryObject
.
list
();
...
@@ -1072,7 +1090,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
...
@@ -1072,7 +1090,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Override
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
public
Iterator
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
public
Iterator
<?>
doInHibernate
(
Session
session
)
throws
HibernateException
{
org
.
hibernate
.
Query
queryObject
=
session
.
createQuery
(
queryString
);
org
.
hibernate
.
Query
queryObject
=
(
org
.
hibernate
.
Query
)
ReflectionUtils
.
invokeMethod
(
createQueryMethod
,
session
,
queryString
);
prepareQuery
(
queryObject
);
prepareQuery
(
queryObject
);
if
(
values
!=
null
)
{
if
(
values
!=
null
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
...
@@ -1100,7 +1119,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
...
@@ -1100,7 +1119,8 @@ public class HibernateTemplate implements HibernateOperations, InitializingBean
@Override
@Override
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
@SuppressWarnings
({
"rawtypes"
,
"deprecation"
})
public
Integer
doInHibernate
(
Session
session
)
throws
HibernateException
{
public
Integer
doInHibernate
(
Session
session
)
throws
HibernateException
{
org
.
hibernate
.
Query
queryObject
=
session
.
createQuery
(
queryString
);
org
.
hibernate
.
Query
queryObject
=
(
org
.
hibernate
.
Query
)
ReflectionUtils
.
invokeMethod
(
createQueryMethod
,
session
,
queryString
);
prepareQuery
(
queryObject
);
prepareQuery
(
queryObject
);
if
(
values
!=
null
)
{
if
(
values
!=
null
)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录