Toplink 客户端会话
有什么方法可以从另一个客户端会话访问一个客户端会话的对象吗?
Is there any way i can access the object of one client session from another client session?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除非您已将实体隔离到客户端会话 (ClassDescriptor.setIsIsolated),否则 ClientSession 实际上并不保存任何实体实例。因此,除非您禁用了缓存,否则针对 ClientSession 的所有查询都将返回相同的实体实例。
如果您有隔离的实体或实际上正在使用 UnitOfWork,那么您将必须从持有的 UnitOfWork/IsolatedClientSession 中获取值。不建议使用多个线程同时访问 UnitOfWork 或 ClientSession。
Unless you have isolated your Entities to the client Session (ClassDescriptor.setIsIsolated) then the ClientSession does not actually hold any entity instances. So unless you have caching disabled all queries against a ClientSession will return the same entity instances.
If you have isolated Entities or are actually using a UnitOfWork then you will have to get the value from the holding UnitOfWork/IsolatedClientSession. It is not advisable to access a UnitOfWork or ClientSession concurrently with multiple threads.
我不确定你想要实现什么,但是根据 服务器和客户端会话 来自 TopLink 开发人员指南,您不应该跨多个线程共享客户端会话:
您能解释一下为什么需要这个吗?
I'm not sure to get what you're trying to achieve but, according to Server and Client Sessions from the TopLink Developer Guide, you're not supposed to share client session accross multiple threads:
Could you clarify why you would need this?