<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Transactional native queries on external database</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120696013" />
  <subtitle>Transactional native queries on external database</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=120696013</id>
  <updated>2026-06-01T07:58:24Z</updated>
  <dc:date>2026-06-01T07:58:24Z</dc:date>
  <entry>
    <title>RE: Transactional native queries on external database</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120841126" />
    <author>
      <name>Enrico Costanzi</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120841126</id>
    <updated>2021-06-22T14:21:36Z</updated>
    <published>2021-06-22T14:21:36Z</published>
    <summary type="html">&lt;p&gt;According to &lt;a
    href="https://stackoverflow.com/questions/67201619/how-can-i-do-a-transactional-method-in-liferay-7-3 "&gt;this
    stackoverflow answer&lt;/a&gt; it's the transaction can be opened either
  manually or by using BaseTransactionalMVCActionCommand .&lt;/p&gt;
&lt;p&gt;I'm still trying to understand if native queries can be mapped on
  POJOs (without using service builder).&lt;/p&gt;</summary>
    <dc:creator>Enrico Costanzi</dc:creator>
    <dc:date>2021-06-22T14:21:36Z</dc:date>
  </entry>
  <entry>
    <title>Transactional native queries on external database</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120696012" />
    <author>
      <name>Enrico Costanzi</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=120696012</id>
    <updated>2021-06-17T12:43:13Z</updated>
    <published>2021-03-25T15:08:04Z</published>
    <summary type="html">&lt;p&gt;My team and I are porting an old java system to Liferay 7.&lt;/p&gt;
&lt;p&gt;Aside from the Liferay database, we have an &lt;strong&gt;external
  database&lt;/strong&gt; to interact with, and we have &lt;strong&gt;both to read
    and write on it&lt;/strong&gt;. &lt;strong&gt;Most of the SQL queries are
    already written and we would like to use them in the new system.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;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:&lt;/p&gt;
&lt;p&gt;- some native queries cannot be mapped to an entity, since we cannot
  identify and ID for them&lt;/p&gt;
&lt;p&gt;- we need to define transactional boundaries at the service
  level, AFAIK as developers we are not allowed to use the
  @transactional annotation&lt;/p&gt;
&lt;p&gt;What's the best strategy for this particular case? Is there something
  similar to JDBCTemplate or JDBI available for use?&lt;/p&gt;</summary>
    <dc:creator>Enrico Costanzi</dc:creator>
    <dc:date>2021-03-25T15:08:04Z</dc:date>
  </entry>
</feed>
