title: PostgreSQL, Atomikos and PREPARE transaction
body: <p>I stack with next problem: my application which consist of Tomcat 8, Java 11, Spring 5, Atomikos 5, PostgreSQL 9.3.5 throw some strange errors. In Spring Repository I have method, which run native SQL query with temp tables creating and then perform some SELECTs. And at first method call I have next log output:</p>
  <pre><code>Hibernate: /* dynamic native SQL query */  DROP TABLE IF EXISTS all_character;  CREATE TEMP TABLE all_character AS (...);  DROP TABLE IF EXISTS character_last_cut; 
  Hibernate: /* dynamic native SQL query */ SELECT * FROM ( SELECT sort_num ...
  Hibernate: /* dynamic native SQL query */  DROP TABLE IF EXISTS character_last_cut_ch_column;
  15:52:45,284 ERROR XAResourceTransaction:66 - XA resource 'commonDataSource': prepare for XID 'XID: 3139322E3136382E302E3130322E746D313631373336343336353139373030303532:3139322E3136382E302E3130322E746D3532' raised -7: the XA resource has become unavailable
  org.postgresql.xa.PGXAException: Error preparing transaction. prepare xid=XID: 3139322E3136382E302E3130322E746D313631373336343
  ... 
  Caused by: org.postgresql.util.PSQLException: ERROR: cannot PREPARE a transaction that has operated on temporary tables
      at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
      at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
  </code></pre>
  <p>and it's right in accordance with &quot;It is not currently allowed to PREPARE a transaction that has executed any operations involving temporary tables, ...&quot; - <a href="https://www.postgresql.org/docs/9.3/sql-prepare-transaction.html" rel="nofollow noreferrer">https://www.postgresql.org/docs/9.3/sql-prepare-transaction.html</a></p>
  <p>But at the next method calls all work fine without any errors. Why that error throwed only at first method call and not throwed by followed calls?</p>