Message Boards

Transactional native queries on external database

Enrico Costanzi, modified 2 Years ago.

Transactional native queries on external database

New Member Posts: 7 Join Date: 8/4/20 Recent Posts

My team and I are porting an old java system to Liferay 7.

Aside from the Liferay database, we have an external database to interact with, and we have both to read and write on itMost of the SQL queries are already written and we would like to use them in the new system.

The only resource I've found is this: https://help.liferay.com/hc/en-us/articles/360018179071-Developing-Custom-SQL-Queries but it doesn't seem to address all our problems, in particular:

- some native queries cannot be mapped to an entity, since we cannot identify and ID for them

- we need to define transactional boundaries at the service level, AFAIK as developers we are not allowed to use the @transactional annotation

What's the best strategy for this particular case? Is there something similar to JDBCTemplate or JDBI available for use?

Enrico Costanzi, modified 2 Years ago.

RE: Transactional native queries on external database

New Member Posts: 7 Join Date: 8/4/20 Recent Posts

According to this stackoverflow answer it's the transaction can be opened either manually or by using BaseTransactionalMVCActionCommand .

I'm still trying to understand if native queries can be mapped on POJOs (without using service builder).