Liferay 交易方法
我从 Liferay 论坛复制 - 两周内没有得到答复。 http://www.liferay.com/community/forums/-/message_boards /message/9384663
我正在寻找文档/博客如何进行 Liferay 事务。
Liferay 6.0.6 PostgreSQL
我对 jax-ws Web 服务有兴趣。 我只使用 Liferay 服务。
例如插入文档并标记它
fileEntry = DLFileEntryServiceUtil.addFileEntry(groupId, folderId, filename, filename, description, changeLog, "extraSettings", buffer, serviceContext);
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), fileEntry.getFolderId());
AssetTagUtil.addAssetEntry(assetTagObj.getPrimaryKey(), assetEntry.getPrimaryKey());
我需要设置交易。
我的类注释
@MTOM
@WebService(targetNamespace="http://services.portal.xyz/",serviceName="AuditResultService",name = "AuditResult", endpointInterface = "xyz.portal.services.AuditResultWS")
@Transactional(isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = {PortalException.class, SystemException.class, InvalidParameterException.class, NoSuchEntryException.class})
@Transactional 是 liferay 的一种
方法,仅使用
@WebMethod
WS 注释效果很好,但没有事务 - 创建文档并且在 NoSuchEntryException 文档保留在 Liferay 中之后。
基于以下尝试的论坛帖子: http://www.liferay.com/community/forums/-/message_boards /message/9019161
portal-ext.properties
transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager
transaction.manager.property.allowCustomIsolationLevels=true
transaction.manager.property.globalRollbackOnParticipationFailure=true
我没有在钩子弹簧配置中执行任何操作。
我尝试改变隔离等但没有成功。
请问有指导吗?
非常感谢
I am copying from Liferay forum - didn't get answer in 2 weeks.
http://www.liferay.com/community/forums/-/message_boards/message/9384663
I am looking for document/blog How to Liferay Transaction.
Liferay 6.0.6
PostgreSQL
I have a hook with jax-ws web services.
I use only Liferay services.
e.g. insert document and tag it
fileEntry = DLFileEntryServiceUtil.addFileEntry(groupId, folderId, filename, filename, description, changeLog, "extraSettings", buffer, serviceContext);
AssetEntry assetEntry = AssetEntryLocalServiceUtil.getEntry(DLFileEntry.class.getName(), fileEntry.getFolderId());
AssetTagUtil.addAssetEntry(assetTagObj.getPrimaryKey(), assetEntry.getPrimaryKey());
I need to setup transaction.
My class annotations
@MTOM
@WebService(targetNamespace="http://services.portal.xyz/",serviceName="AuditResultService",name = "AuditResult", endpointInterface = "xyz.portal.services.AuditResultWS")
@Transactional(isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = {PortalException.class, SystemException.class, InvalidParameterException.class, NoSuchEntryException.class})
@Transactional is liferay one
Method is annotated only with
@WebMethod
WS works great, but no transaction - document is created and after NoSuchEntryException document stays in Liferay.
Based on forum thread below tried:
http://www.liferay.com/community/forums/-/message_boards/message/9019161
portal-ext.properties
transaction.manager.impl=org.springframework.transaction.jta.JtaTransactionManager
transaction.manager.property.allowCustomIsolationLevels=true
transaction.manager.property.globalRollbackOnParticipationFailure=true
I didn't do anything in my hook spring configuration.
I tried to change isolation etc no success.
Please is there any guide?
Thank you very much
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您在事务部分中抛出异常,则任何内容都可能是事务性的。在 liferay 中,事务仅在服务实体的方法(即 ...ServiceUtil 类)内处理。您必须在方法名称前添加 CRUD 操作前缀。所以你必须创建一个“虚拟”实体..这是更简单的方法。
If you throw an exception inside a a transaction section anything could be transactional. In liferay transactions are handled only inside a method of a service entity, namely the ...ServiceUtil class. You have to prefix the method's name with a CRUD operation. So you have to create a "dummy" entity.. it's the simpler way.
你可以尝试这个,
必须在 *impl 类中添加方法,然后它是默认事务。
https://liferay.dev/forums/-/message_boards/message/4928729
You can try this,
have to add method in *impl class then it is by default transaction.
https://liferay.dev/forums/-/message_boards/message/4928729
如果您不一定需要在一个事务中调用所有 3 个方法,请调用 AssetTagServiceUtil 而不是 AssetTagUtil。 addFileEntry 调用在文件系统上创建一个文件,该文件无论如何都不是事务性的。
如果您确实坚持将所有事务合并到一起,则创建一项将从 Web 服务调用的自定义服务。
原因是 Liferay 中的事务管理器仅扫描服务上的 @Transactional 注释。
If you do not necessarily need to call all 3 methods in one transaction call AssetTagServiceUtil instead of AssetTagUtil. The addFileEntry call creates a file on filesystem which isn't transactional anyway.
In case you really insist on having all in one transaction create a custom service that will be called from the web service.
The reason is that trasaction manager in Liferay scans @Transactional annotation only on services.