Home > Database > Mysql Tutorial > mysql-mysq会话变量使用疑惑?

mysql-mysq会话变量使用疑惑?

WBOY
Release: 2016-06-06 09:41:23
Original
879 people have browsed it

mysqlc3p0hibernate

使用存储过程和触发器记录字段修改历史!
存储过程中刚有一个SQL:
INSERT INTO x_change_log (x_ID,, UserName,ColumnName, OldValue, NewValue)
VALUES (xId, @UserName,ColumnName, OldValue, NewValue)
除了@userName,其他变量都是从触发器传过来!
userName由hibernate执行update之前设置值!
getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(
"SET @UserName='" + SpringSecurityUtils.getCurrentUserName()
+ "'").executeUpdate();
getHibernateTemplate().update(entity);

出现的问题是:历史中记录的userName有地混乱!
怀疑是hibernate使用连接池导致的,多个事务共用了一个连接,后面的事务执行set @userName覆盖了前面事务的变量,不知道如何解决!给位大神有什么解决思路吗?
ps:c币不足,见谅!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template