Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将休眠会话绑定到喜欢的线程(QuartzSchude)。因为我有来自应用程序上下文的 sessionFactory 实例。我想将它绑定到电子邮件线程、webservie 线程和等...使用 http req 并响应它工作正常..
您需要通过 AOP 装饰的事务 bean(例如,您的服务层用 注释@Transactional),或者您需要使用TransactionTemplate:
@Transactional
TransactionTemplate
new TransactionTemplate(txManager).execute(new TransactionCallback<Void>() { @Override public Void doInTransaction(TransactionStatus status) { // Your Hibenrate stuff return null; } });