users@glassfish.java.net

Re: JPA-IntermittentThe attribute [] of class [] is mapped to a primary col

From: <glassfish_at_javadesktop.org>
Date: Wed, 21 Nov 2007 12:17:06 PST

Thanks for the suggestions.

Switching to method accessing makes the problem go away. Now, I have had this on several occasions over the last year. Touching part of the code all of sudden makes this problem pop up or go away....as mentioned...just renaming Order to Wrapper makes it disappear

I have tried to debug the Toplink code, and I have the impression that for some reason the flush triggered by the query sometimes messes up some copy of the object (all properties are null/0). Next commit, Toplink then decides it has to be an update. I have no idea why/where that first thing happens though.



[b]1. Here is the stack trace[/b]

Exception [TOPLINK-7251] (Oracle TopLink Essentials - @VERSION@ (Build @BUILD_NUMBER@)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [Node] is mapped to a primary key column in the database. Updates are not allowed.
        at oracle.toplink.essentials.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2222)
        at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:750)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:948)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1263)
        at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:91)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:311)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:195)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1126)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:107)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:856)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:102)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
        at Fails.execute(Fails.java:60)
        at Fails.main(Fails.java:36)


[b]Here is some FINEST level log info/b]

A loop that succeeds gives ( there are few system.out.println i added as well)

[TopLink Finer]: Thread(Thread[main,5,main])--resume unit of work
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(20721023)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/]
[TopLink Finest]: Thread(Thread[main,5,main])--Register the existing object Node_at_186ed7a
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Node_at_1e40274.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (3 -> Node_at_1e40274)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Leaf_at_bc312f.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (4 -> Leaf_at_bc312f)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Node_at_1d978ea.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (5 -> Node_at_1d978ea)
[TopLink Finer]: Connection(31639617)--Thread(Thread[main,5,main])--begin transaction
commitNewObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Node)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query InsertObjectQuery(Node_at_1e40274)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_1079ff)
[TopLink Fine]: Connection(31639617)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [3, /d/d/, 2, 2]
commitNewObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Node)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query InsertObjectQuery(Node_at_1d978ea)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_1e40274)
[TopLink Fine]: Connection(31639617)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [5, /d/d/d/, 3, 2]
commitNewObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Leaf)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query InsertObjectQuery(Leaf_at_bc312f)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_1e40274)
[TopLink Fine]: Connection(31639617)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [4, /d/d/f, 3, 1]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(31639617)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/dd]
[TopLink Finer]: Thread(Thread[main,5,main])--begin unit of work commit
[TopLink Finer]: Connection(31639617)--Thread(Thread[main,5,main])--commit transaction
[TopLink Finer]: Thread(Thread[main,5,main])--end unit of work commit
[TopLink Finer]: Thread(Thread[main,5,main])--resume unit of work
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(23968266)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/d/d/]
[TopLink Finest]: Thread(Thread[main,5,main])--Register the existing object Node_at_916f80
[TopLink Finest]: Thread(Thread[main,5,main])--The remove operation has been performed on: Node_at_1d978ea
[TopLink Finer]: Connection(23270771)--Thread(Thread[main,5,main])--begin transaction
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DeleteObjectQuery(Node_at_1d978ea)
[TopLink Fine]: Connection(23270771)--Thread(Thread[main,5,main])--DELETE FROM node WHERE (id = ?)
        bind => [5]
[TopLink Finest]: Thread(Thread[main,5,main])--Unregister the object Node_at_1d978ea
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(23270771)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/d/f]
[TopLink Finest]: Thread(Thread[main,5,main])--The remove operation has been performed on: Leaf_at_bc312f
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DeleteObjectQuery(Leaf_at_bc312f)
[TopLink Fine]: Connection(23270771)--Thread(Thread[main,5,main])--DELETE FROM node WHERE (id = ?)
        bind => [4]
[TopLink Finest]: Thread(Thread[main,5,main])--Unregister the object Leaf_at_bc312f
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(23270771)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/d/]
[TopLink Finest]: Thread(Thread[main,5,main])--The remove operation has been performed on: Node_at_1e40274
[TopLink Finer]: Thread(Thread[main,5,main])--begin unit of work commit
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DeleteObjectQuery(Node_at_1e40274)
[TopLink Fine]: Connection(23270771)--Thread(Thread[main,5,main])--DELETE FROM node WHERE (id = ?)
        bind => [3]
[TopLink Finer]: Connection(23270771)--Thread(Thread[main,5,main])--commit transaction
[TopLink Finer]: Thread(Thread[main,5,main])--end unit of work commit
[TopLink Finer]: Thread(Thread[main,5,main])--resume unit of work
Ok

One that fails gives

[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(20721023)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/]
[TopLink Finest]: Thread(Thread[main,5,main])--Register the existing object Node_at_186ed7a
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Node_at_10cafa1.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (6 -> Node_at_10cafa1)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Leaf_at_1b88122.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (7 -> Leaf_at_1b88122)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query DoesExistQuery()
[TopLink Finest]: Thread(Thread[main,5,main])--PERSIST operation called on: Node_at_8b6c39.
[TopLink Finest]: Thread(Thread[main,5,main])--assign sequence to the object (8 -> Node_at_8b6c39)
[TopLink Finer]: Connection(14173353)--Thread(Thread[main,5,main])--begin transaction
commitNewObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Node)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query InsertObjectQuery(Node_at_8b6c39)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_10cafa1)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_1079ff)
[TopLink Fine]: Connection(14173353)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [6, /d/d/, 2, 2]
[TopLink Fine]: Connection(14173353)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [8, /d/d/d/, 6, 2]
commitNewObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Leaf)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query InsertObjectQuery(Leaf_at_1b88122)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_10cafa1)
[TopLink Fine]: Connection(14173353)--Thread(Thread[main,5,main])--INSERT INTO node (id, path, parent_id, type) VALUES (?, ?, ?, ?)
        bind => [7, /d/d/f, 6, 1]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query ReportQuery(BaseNode)
[TopLink Fine]: Connection(14173353)--Thread(Thread[main,5,main])--SELECT id, type, path, parent_id FROM node WHERE (path = ?)
        bind => [/d/dd]
[TopLink Finer]: Thread(Thread[main,5,main])--begin unit of work commit
commitChangedObjectsForClassWithChangeSet-changeSetToWrite:oracle.toplink.essentials.internal.sessions.ObjectChangeSet(Node)[oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(id), oracle.toplink.essentials.internal.sessions.DirectToFieldChangeRecord(path), oracle.toplink.essentials.internal.sessions.ObjectReferenceChangeRecord(parent)]
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query UpdateObjectQuery(Node_at_10cafa1)
[TopLink Finest]: Thread(Thread[main,5,main])--Execute query WriteObjectQuery(Node_at_1079ff)
[TopLink Warning]: Thread(Thread[main,5,main])--Local Exception Stack:
Exception [TOPLINK-7251] (Oracle TopLink Essentials - @VERSION@ (Build @BUILD_NUMBER@)): oracle.toplink.essentials.exceptions.ValidationException
Exception Description: The attribute [id] of class [Node] is mapped to a primary key column in the database. Updates are not allowed.
        at oracle.toplink.essentials.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2222)
        at oracle.toplink.essentials.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:750)
        at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:948)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1263)
        at oracle.toplink.essentials.queryframework.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:91)
        at oracle.toplink.essentials.internal.queryframework.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:390)
        at oracle.toplink.essentials.queryframework.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:109)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.execute(DatabaseQuery.java:628)
        at oracle.toplink.essentials.queryframework.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:555)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:138)
        at oracle.toplink.essentials.queryframework.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:110)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2233)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:952)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:909)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:311)
        at oracle.toplink.essentials.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:195)
        at oracle.toplink.essentials.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:2657)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1044)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:403)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1126)
        at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:107)
        at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:856)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:102)
        at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
        at Fails.execute(Fails.java:60)
        at Fails.main(Fails.java:36)

[TopLink Finer]: Connection(14173353)--Thread(Thread[main,5,main])--rollback transaction
[TopLink Finer]: Thread(Thread[main,5,main])--release unit of work
[TopLink Finer]: Thread(Thread[main,5,main])--initialize identitymaps
[TopLink Finer]: Thread(Thread[main,5,main])--client released
Failed
[Message sent by forum member 'pgp_coppens' (pgp_coppens)]

http://forums.java.net/jive/thread.jspa?messageID=246653