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

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

 
From: James Sutherland <jamesssss@xxxxxxxxx>
To: eclipselink-users@xxxxxxxxxxx
Date: Mon, 1 Mar 2010 11:48:14 -0800 (PST)
Subject: Re: [eclipselink-users] Run-time exception with EclipseLink JPA 2.0 Employee example

I do not get this issue.  Could you include the full exception stack trace.

Ensure you are using EclipseLink 2.0, and JPA 2.0.


lb.alvaro wrote:
>
> I'm trying to run the EclipseLink JPA 2.0 Employee example:
>   http://wiki.eclipse.org/EclipseLink/Examples/JPA/2.0/Employee
>
> I created a NetBeans project and configured persistence.xml to use Apache
> Derby.  It compiles fine, but when I run the Populate program, I get the
> following run-time exception:
>
> 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)
>
>
> Any suggestions on how to get this example project to run correctly?
>
> On a related note, NetBeans reports warning at line 70 of Employee.java:
> The attribute column name (PERIOD) is a reserved SQL:1999 keyword
>
> Thanks in advance for any responses.
> Alvaro
>
>

Back to the top