Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Run-time exception with EclipseLink JPA 2.0 Employee example

It is odd that it is trying to update the object, as this is the populate
which is doing a persist.  Do you have existing data in the database? 
Perhaps try a clean database run, or try running outside of NetBeans.



lb.alvaro wrote:
> 
> Hi James.  Thanks for trying it out.  I thought there might be something
> I'm
> doing wrong.
> 
> FYI, I'm using NetBeans 6.8 with GlassFish v3 installed.  The libraries on
> the project are:
> derby.jar
> derbyclient.jar
> derbynet.jar
> eclipselink-2.0.0.jar
> eclipselink-javax.persistence-2.0.jar
> 
> Is there an easy way to test if I'm using EclipseLink 2.0 and JPA 2.0?  I
> mean I have the libraries in the project.  Is that not enough?
> 
> Thanks!
> Alvaro
> 
> The stack trace follows:
> [EL Warning]: Exception [EclipseLink-7251] (Eclipse Persistence Services -
> 2.0.0.v20091127-r5931):
> org.eclipse.persistence.exceptions.ValidationException
> Exception Description: The attribute [type] of class [model.PhoneNumber]
> is
> mapped to a primary key column in the database. Updates are not allowed.
> Exception in thread "main" javax.persistence.RollbackException: Exception
> [EclipseLink-7251] (Eclipse Persistence Services - 2.0.0.v20091127-r5931):
> org.eclipse.persistence.exceptions.ValidationException
> Exception Description: The attribute [type] of class [model.PhoneNumber]
> is
> mapped to a primary key column in the database. Updates are not allowed.
>         at
> org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:102)
>         at
> org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:63)
>         at example.Populate.populate(Populate.java:40)
>         at example.Populate.main(Populate.java:32)
> Caused by: Exception [EclipseLink-7251] (Eclipse Persistence Services -
> 2.0.0.v20091127-r5931):
> org.eclipse.persistence.exceptions.ValidationException
> Exception Description: The attribute [type] of class [model.PhoneNumber]
> is
> mapped to a primary key column in the database. Updates are not allowed.
>         at
> org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2400)
>         at
> org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:1271)
>         at
> org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:1070)
>         at
> org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1104)
>         at
> org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:84)
>         at
> org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:286)
>         at
> org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:58)
>         at
> org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:675)
>         at
> org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:589)
>         at
> org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:109)
>         at
> org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:86)
>         at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2863)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1225)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1207)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1167)
>         at
> org.eclipse.persistence.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:233)
>         at
> org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsForClassWithChangeSet(CommitManager.java:163)
>         at
> org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:116)
>         at
> org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:3260)
>         at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1405)
>         at
> org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitToDatabase(RepeatableWriteUnitOfWork.java:547)
>         at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1510)
>         at
> org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:200)
>         at
> org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1131)
>         at
> org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commitInternal(EntityTransactionImpl.java:84)
>         ... 3 more
> Java Result: 1
> 
> 
> 


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://old.nabble.com/Re%3A-Run-time-exception-with-EclipseLink-JPA-2.0--Employee-example-tp27750562p27836845.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top