我有代码怀疑 [英] Code doubt I have
本文介绍了我有代码怀疑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在休眠状态下,如何在每次插入操作之前放置以下代码:以login = user2身份执行":
How can I put this code: "execute as login=user2" before each insert operation, on hibernate:
Session session = getSession();
session.getTransaction().begin();
session.persist(o);//put here when execute a normal insert
session.getTransaction().commit();
推荐答案
您的对象有一个登录字段?如果是,请使用Java可用的一些动态代理,并拦截调用以设置此值.
Your object has got a login field? If yes, use some of the dynamic proxies available for Java and intercept the call to set this value.
这篇关于我有代码怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文