Andrej Badinka created OPENJPA-2639:
---------------------------------------
Summary: OptimisticLock on Partitioned tables
Key: OPENJPA-2639
URL: https://issues.apache.org/jira/browse/OPENJPA-2639
Project: OpenJPA
Issue Type: Bug
Components: kernel
Affects Versions: 2.3.0
Reporter: Andrej Badinka
We created partition tables as it is described in the guide on
http://www.postgresql.org/docs/9.1/static/ddl-partitioning.html .
I have a function that inserts records to partition table depending on date and
a trigger that calls that function, like in the documentation.
When i try to persist new entity in transaction to this partitioned log_table,
I get an exception on commiting:
{quote}
Caused by: <openjpa-2.3.0-r422266:1540826 nonfatal store error>
org.apache.openjpa.persistence.OptimisticLockException: An optimistic lock
violation was detected when flushing object instance
"...entities.LogTable@4a6e9cd6" to the data store. This indicates that the
object was concurrently modified in another transaction.
FailedObject: ...entities.LogTable@4a6e9cd6
at
org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(PreparedStatementManagerImpl.java:124)
{quote}
Near that lines there is a code
{quote}
int count = executeUpdate(stmnt, sql, row);
if (count != 1) {
logSQLWarnings(stmnt);
{quote}
that is causing this exception I assume. On Postgres page there is an issue
regarding this
http://www.postgresql.org/message-id/[email protected] and
they state that the behaviour of returning 0 is common.
The difference in inserting on normal table and partitioned table is:
When I insert one record manualy using INSERT on partitioned table it works,
but returns "Query returned successfully: *0 rows affected*, 54 ms execution
time."
Without the trigger, the manual INSERT command returns "Query returned
successfully: *one row affected*, 51 ms execution time."
Without the trigger, it works OK in java code, so the java code should be ok. I
do nothing exceptional for persisting the entity.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)