Grails使连接休眠变化动态 [英] Grails make the connection to hibernate change dynamically

查看:86
本文介绍了Grails使连接休眠变化动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据登录的应用程序用户动态修改hibernate的连接。
I.E.每个应用程序用户都有自己的oracle模式。为此,我根据已登录的用户动态地从代码中更改 dataSourceUnproxied.username dataSourceUnproxied.password 的值,然后关闭连接并获得连接再次使用新的设置。它工作正常,但问题是如果两个用户同时登录到我的应用程序,则连接将设置为最后登录用户的连接,并且两个用户都将使用相同的再次连接。看起来这些变量是应用程序范围变量,它为所有用户设置了值。



有没有一种方法可以根据用户会话使这些值有所不同?

解决方案

div>

我认为你的问题类似于这个
http://grails.1312388.n4.nabble.com/unique-dataSource-per-HttpSession-td1343203.html



基本上,你可以拿出你自己的数据源实现。



我相信它可以帮助你解决你的问题。

I’m trying to make the connection to hibernate change dynamically based on the application user logged in. I.E. Every application user will have his own oracle schema. To do so, I changed the values of dataSourceUnproxied.username and dataSourceUnproxied.password dynamically from the code depending on the logged on user, then I closed the connection and got the connection again with the new settings. It worked, but the problem is if two users are logged in to my application at the same time, the connection will be set to the connection of the last logged in user, and both users will use the same connection again. It seems that these variables are application scoped variables, which set the value for all the users.

Is there a way to make these values different based on the user session?

解决方案

I think that your question is similar to this one http://grails.1312388.n4.nabble.com/unique-dataSource-per-HttpSession-td1343203.html

Basically you could come up with your own datasource implementation.

I believe that it may help you solve your issue with minor dark corners.

这篇关于Grails使连接休眠变化动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆