openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ernesto Ricci (Created) (JIRA)" <>
Subject [jira] [Created] (OPENJPA-2072) InvalidStateException deleting an instance with a timestamp in its primary key
Date Wed, 09 Nov 2011 08:13:51 GMT
InvalidStateException deleting an instance with a timestamp in its primary key

                 Key: OPENJPA-2072
             Project: OpenJPA
          Issue Type: Bug
    Affects Versions: 1.2.2, 1.2.1, 1.2.3
         Environment: Linux, JUnit + Spring and HSQLDB in a case; Windows, WebSphere and DB2
in another case
            Reporter: Ernesto Ricci

Attempting to remove an instance that has a timestamp field in its primary key results in
this error:
org.apache.openjpa.persistence.InvalidStateException: Operation attempted on a deleted instance.

Suppose I have this table:
CREATE TABLE test_tsp (
   t Timestamp,
   desc char(30)

containing just the following row:

the table is mapped to this JPA Entity
public class TestTsp implements Serializable {
 private static final long serialVersionUID = -5756434331459759089L;
 private Timestamp idTsp;

 private String desc;

 public TestTsp() {
...getters and setters here...

and the following code attempts a delete of the row I've inserted

 Query query = em.createQuery("select t from TestTsp t where t.desc='one'");
 List<TestTsp> list = query.getResultList();
 for (TestTsp t : list) {

Here is the error I get:
Caused by: <openjpa-1.2.2-r422266:898935 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException:
Operation attempted on a deleted instance.
FailedObject: org.apache.openjpa.enhance.provatsp$TestTsp$pcsubclass@3c0b655a
        at org.apache.openjpa.kernel.PCState.error(
        at org.apache.openjpa.kernel.PDeletedState.beforeOptimisticWrite(
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(
        at org.apache.openjpa.kernel.StateManagerImpl.dirty(
        at org.apache.openjpa.util.Proxies.dirty(
        at$sql$Timestamp$proxy.setNanos(Unknown Source)
        at org.apache.openjpa.jdbc.sql.DBDictionary.setTimestamp(
        at org.apache.openjpa.jdbc.sql.DBDictionary.setTyped(
        at org.apache.openjpa.jdbc.sql.RowImpl.flush(
        at org.apache.openjpa.jdbc.sql.RowImpl.flush(
        at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushAndUpdate(
        at org.apache.openjpa.jdbc.kernel.BatchingPreparedStatementManagerImpl.flushAndUpdate(
        at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flushInternal(
        at org.apache.openjpa.jdbc.kernel.PreparedStatementManagerImpl.flush(
        at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(
        at org.apache.openjpa.jdbc.kernel.ConstraintUpdateManager.flush(
        at org.apache.openjpa.jdbc.kernel.BatchingConstraintUpdateManager.flush(
        at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
        at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
        at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(
        at org.apache.openjpa.kernel.DelegatingStoreManager.flush(
        ... 40 more

N.B.: the error doesn't happen if the primary key annotation (@Id) is moved on the other field
of the entity, which is not a timestamp but a char:
 private Timestamp idTsp;

 private String desc;

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message