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 = AssetEntryLocalS开发者_如何学JAVAerviceUtil.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
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.
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
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.
精彩评论