我在系统中缓存了user对象,同时user对象中关联实体company,office两个对象
同时我的所有的用户的添加修改都会对缓存进行操作.即清除重写 但是,如果我修改了company对象后,缓存中的user对象没有进行缓存修改处理,则登录用户从user.getCompany()中取出来的还是原来 的公司名称.如:缓存中的公司名称是A,而更改后的是B,则如果从user.getCompany()取出来的还是A,但是实际上数据库当中已经是B了,我该如何做? 如果是我对company进行了修改后,关联修改user对象,则不会有上述问题.但是如果公司下面的用户过多的话,那么效率会很低的啊.况且我的用户下面还关联了很多的角色,权限信息.
大家有什么好的方法吗?
同时我的所有的用户的添加修改都会对缓存进行操作.即清除重写 但是,如果我修改了company对象后,缓存中的user对象没有进行缓存修改处理,则登录用户从user.getCompany()中取出来的还是原来 的公司名称.如:缓存中的公司名称是A,而更改后的是B,则如果从user.getCompany()取出来的还是A,但是实际上数据库当中已经是B了,我该如何做? 如果是我对company进行了修改后,关联修改user对象,则不会有上述问题.但是如果公司下面的用户过多的话,那么效率会很低的啊.况且我的用户下面还关联了很多的角色,权限信息.
大家有什么好的方法吗?
解决方案 »
- 新手关于JSP调用javaBean的问题。
- sqlserver 2005 怎样根据日期每天自动生成一张 表名就是当前的日期
- 为什么没有JAVA版的MySQL proxy??
- HQL语句在有sum(),group by函数的时候如何返回一个javabean 而不是object数组
- Sun Java Application Server是收费的么?
- struts整合spring的全权代理方法异常,恳求高手帮忙
- 将数据库中的数据导出成excel表格形式
- 用installanywhere 把web程序及tomcat和Access安装到用户机器上,并且自动注册为服务并启动 在线等待(100分)
- 求一个MVC的简单例子!
- 谁能给我一个例子:用Java写的客户端调用服务器上的EJB。
- hibernate 自关联修改出错
- jsp wml 服务器端接受到的是乱码 帮忙解决哈,编码都设的UTF-8
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Area.staffs" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Area.offices" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Office" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff.area" maxElementsInMemory="500" overflowToDisk="true"
eternal="false" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff.roles" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Role" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Role.staffs" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Role.privileges" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache> <cache name="com.sdcncsi.entity.sys.Privilege" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/>
<cache name="com.sdcncsi.entity.sys.Privilege.roles" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/>
<cache name="com.sdcncsi.entity.sys.Privilege.resources" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/>
<cache name="com.sdcncsi.entity.sys.Resource" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120"/>
登录的时候,读取用户信息也是从缓存中读取的.
不过我增加修改用户信息都要添加到缓存中.但是就是对company(也就是配置文件中的area)无法关联.难道是没有配置级联吗?
<cache name="com.sdcncsi.entity.sys.Area" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff.area" maxElementsInMemory="500" overflowToDisk="true"
eternal="false" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
改成
<cache name="com.sdcncsi.entity.sys.Area" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
<cache name="com.sdcncsi.entity.sys.Staff" maxElementsInMemory="500" overflowToDisk="true"
eternal="true" timeToIdleSeconds="1200" timeToLiveSeconds="7200"
diskPersistent="false" diskExpiryThreadIntervalSeconds="120">
</cache>
也就是说不要缓存Staff的area这个关系。
我的用户列表当中的数据,如果company由A改为B后已经显示成为B了,但是
我放入上下文中的信息却还是A,我用的是springSecurity,它的上下文中的信息还是A我不知道你是否胜过这个安全框架,也就是acegi
我一般都会通过staff.getCompany()来取的.当然了,用户列表当中的getCompany().getCompnayName()是正确的.
而上下文中的那个却是错误的.难道我们需要手动清除吗?