Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink Validation Exception in Library Eclipse Version 2.7.8(Updates are not allowed)
EclipseLink Validation Exception in Library Eclipse Version 2.7.8 [message #1850202] Mon, 21 February 2022 14:34 Go to next message
Archit Sanghi is currently offline Archit SanghiFriend
Messages: 1
Registered: February 2022
Junior Member
We have created Dynamic Entities and we have a table called Movies.
Movies has following structure
Name Null? Type
------ -------- -------------
ID NOT NULL NUMBER(38)
NAME VARCHAR2(256)
ACTOR VARCHAR2(256)
RATING NUMBER(38)
where ID is the PK to the table Movies


The mappings are set in the dynamic entities using the following code

//Create dynamic class for given object
JPADynamicTypeBuilder dynamicTypeBuilder = createDynamicEntity(entityModel.getEntityName(), dataSource);
//Add column mapping to entity
for (Map.Entry<String, Pair<String, String>> entry : entityModel.getColumnMapping().entrySet()) {
log.debug("Add DirectMapping: field {} and column {}", entry.getKey(), entry.getValue().getKey());
dynamicTypeBuilder.addDirectMapping(
entry.getKey(),
PersistenceConstants.persistenceTypeMap.get(entry.getValue().getValue()),
entry.getValue().getKey()
);
}
// Add primaryKey Fields
dynamicTypeBuilder.setPrimaryKeyFields(entityModel.getPrimaryKeys().toArray(
new String[entityModel.getPrimaryKeys().size()]));
....

// Add created dynamic type to helper :
helper.addTypes(false, false, dynamicTypes);



We had the following code for performing an update operation on a given row.

EntityManager entityManager = customEntityManagerFactory.getEntityManager(dataSource);
try {
entityManager.getTransaction().begin();
entityManager.merge(entity); // entity = {id : 3 name = "harry potter"}
entityManager.getTransaction().commit();
} catch (RuntimeException e) {
e.printStackTrace();
throw new MutationException(String.format("Update entity FAILED for datasource: %s, entity: %s", dataSource,
entity));
}
customEntityManagerFactory.closeEntityManager(dataSource);

While executing the above function we are experiencing an error with the below stack trace.

Local Exception Stack:
2022-02-21_13:17:29.53994 Exception [EclipseLink-7251] (Eclipse Persistence Services - 2.7.8.v20201217-ecdf3c32c4): org.eclipse.persistence.exceptions.ValidationException
2022-02-21_13:17:29.53994 Exception Description: The attribute [id] of class [com.oracle.graphqlDBforQuerySD.STUDENTS] is mapped to a primary key column in the database. Updates are not allowed.
2022-02-21_13:17:29.53995 at org.eclipse.persistence.exceptions.ValidationException.primaryKeyUpdateDisallowed(ValidationException.java:2553)
2022-02-21_13:17:29.53995 at org.eclipse.persistence.mappings.foundation.AbstractDirectMapping.writeFromObjectIntoRowWithChangeRecord(AbstractDirectMapping.java:1254)
2022-02-21_13:17:29.53995 at org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildRowForUpdateWithChangeSet(ObjectBuilder.java:1779)
2022-02-21_13:17:29.53995 at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.updateObjectForWriteWithChangeSet(DatabaseQueryMechanism.java:1045)
2022-02-21_13:17:29.53996 at org.eclipse.persistence.queries.UpdateObjectQuery.executeCommitWithChangeSet(UpdateObjectQuery.java:86)
2022-02-21_13:17:29.53996 at org.eclipse.persistence.internal.queries.DatabaseQueryMechanism.executeWriteWithChangeSet(DatabaseQueryMechanism.java:316)
2022-02-21_13:17:29.53997 at org.eclipse.persistence.queries.WriteObjectQuery.executeDatabaseQuery(WriteObjectQuery.java:60)
2022-02-21_13:17:29.53997 at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:911)
2022-02-21_13:17:29.53997 at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:810)
2022-02-21_13:17:29.53997 at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWorkObjectLevelModifyQuery(ObjectLevelModifyQuery.java:110)
2022-02-21_13:17:29.53998 at org.eclipse.persistence.queries.ObjectLevelModifyQuery.executeInUnitOfWork(ObjectLevelModifyQuery.java:87)
2022-02-21_13:17:29.53998 at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2983)
2022-02-21_13:17:29.53999 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1898)
2022-02-21_13:17:29.53999 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1880)
2022-02-21_13:17:29.53999 at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1830)
2022-02-21_13:17:29.54000 at org.eclipse.persistence.internal.sessions.CommitManager.commitChangedObjectsForClassWithChangeSet(CommitManager.java:275)
2022-02-21_13:17:29.54000 at org.eclipse.persistence.internal.sessions.CommitManager.commitAllObjectsWithChangeSet(CommitManager.java:133)
2022-02-21_13:17:29.54000 at org.eclipse.persistence.internal.sessions.AbstractSession.writeAllObjectsWithChangeSet(AbstractSession.java:4398)
2022-02-21_13:17:29.54000 at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabase(UnitOfWorkImpl.java:1495)
2022-02-21_13:17:29.54001 at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitToDatabaseWithChangeSet(UnitOfWorkImpl.java:1585)
2022-02-21_13:17:29.54001 at org.eclipse.persistence.internal.sessions.RepeatableWriteUnitOfWork.commitRootUnitOfWork(RepeatableWriteUnitOfWork.java:280)
2022-02-21_13:17:29.54001 at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.commitAndResume(UnitOfWorkImpl.java:1222)
2022-02-21_13:17:29.54001 at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:136)
2022-02-21_13:17:29.54002 at com.oracle.graphql.api.persistence.mutation.MutationExecution.updateEntityExec(MutationExecution.java:117)
2022-02-21_13:17:29.54002 at com.oracle.graphql.api.persistence.mutation.MutationWrapper.updateEntity(MutationWrapper.java:159)
2022-02-21_13:17:29.54003 at com.oracle.graphql.api.resolvers.dbresolver.DatabaseResolverImpl.update(DatabaseResolverImpl.java:271)
2022-02-21_13:17:29.54003 at com.oracle.graphql.api.datafetchers.FetcherRegistration.lambda$getDatabaseUpdateDataFetcher$11(FetcherRegistration.java:991)
2022-02-21_13:17:29.54003 at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:279)
2022-02-21_13:17:29.54003 at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:210)
2022-02-21_13:17:29.54003 at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:60)
2022-02-21_13:17:29.54004 at graphql.execution.Execution.executeOperation(Execution.java:159)
2022-02-21_13:17:29.54004 at graphql.execution.Execution.execute(Execution.java:105)
2022-02-21_13:17:29.54004 at graphql.GraphQL.execute(GraphQL.java:613)
2022-02-21_13:17:29.54004 at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:538)
2022-02-21_13:17:29.54005 at graphql.GraphQL.executeAsync(GraphQL.java:502)
2022-02-21_13:17:29.54005 at graphql.GraphQL.executeAsync(GraphQL.java:453)
2022-02-21_13:17:29.54006 at com.oracle.graphql.api.execution.GraphQLExecutorService.execute(GraphQLExecutorService.java:53)
2022-02-21_13:17:29.54006 at com.oracle.graphql.resources.GraphqlResource.invoke(GraphqlResource.java:109)
2022-02-21_13:17:29.54006 at com.oracle.graphql.resources.GraphqlResource.post(GraphqlResource.java:67)
2022-02-21_13:17:29.54006 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2022-02-21_13:17:29.54007 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2022-02-21_13:17:29.54007 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2022-02-21_13:17:29.54007 at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2022-02-21_13:17:29.54007 at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
2022-02-21_13:17:29.54008 at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
2022-02-21_13:17:29.54008 at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
2022-02-21_13:17:29.54009 at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ObjectOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:192)
Re: EclipseLink Validation Exception in Library Eclipse Version 2.7.8 [message #1850205 is a reply to message #1850202] Mon, 21 February 2022 16:09 Go to previous message
Nitin Dahyabhai is currently offline Nitin DahyabhaiFriend
Messages: 4430
Registered: July 2009
Senior Member

You did not ask a question.

_
Nitin Dahyabhai
Eclipse Web Tools Platform
Previous Topic:OpenJDK11 and eclipse link 2.7.1 Compatibility issue - Named query not found
Next Topic:JPA project classpath for JDBC driver dependencies
Goto Forum:
  


Current Time: Thu Mar 28 23:19:33 GMT 2024

Powered by FUDForum. Page generated in 0.02230 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top