Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Deadlock or ignored id-validation - I've trouble

Em 31/05/2013 12:30, Andrei Ilitchev escreveu:
Sequencing has nothing to do with shared cache mode, should work with any mode.

By default id validation is set to ZERO for simple primary key and NULL for compound primary key.

Yes.


If you set id validation to NULL for a simple primary key, then all the values except NULL will be accepted as a legitimate pk value and won't be overridden by sequencing.

For example:
public class Employee {
@Id
@GeneratedValue(strategy=TABLE, generator="EMPLOYEE_TABLE_GENERATOR")
@TableGenerator(
    name="EMPLOYEE_TABLE_GENERATOR",
    pkColumnValue="EMPLOYEE_SEQ",
)
int id
...
}

When an Employee object is persisted and it's id=0, if id validation is ZERO, then sequencing fetches a value from sequence table that's assigned to the Employee.

However with id validation set to null:
@PrimaryKey(validation=IdValidation.NULL)
public class Employee {
...
}
the Employee object is inserted in the db with id=0.

If this doesn't help please explain what are you trying to do,
may be provide a simple example.

That's what I expected. I've put in persistence.xml the value "eclipselink.id-validation = 'NULL'", and I expect that Eclipselink honor that. But when I have shared cache "ENABLE_SELECTIVE", then it doesn't honor sequencing for many side of one-to-many relationship. If I put shared cache as "ALL", then it honor sequencing for many side, but then I get deadlock if multiple users are working with objects of same kind.

I've captured the two threads that are frozen when using shared cache ALL, and the threads are frozen here (two thread dumps):

Stack Trace
   java.lang.Thread.sleep line: not available [native method]
org.eclipse.persistence.internal.helper.ConcurrencyManager.releaseDeferredLock line: 466 org.eclipse.persistence.internal.identitymaps.CacheKey.releaseDeferredLock line: 385 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 861 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally line: 719 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork line: 672 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 605 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 564 org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject line: 777 org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork line: 787 org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery line: 460 org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery line: 1150
   org.eclipse.persistence.queries.DatabaseQuery.execute line: 852
   org.eclipse.persistence.queries.ObjectLevelReadQuery.execute line: 1109
   org.eclipse.persistence.queries.ReadObjectQuery.execute line: 421
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork line: 1197 org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery line: 2875 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1602 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1584 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1535 org.eclipse.persistence.internal.jpa.EntityManagerImpl.executeQuery line: 838 org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal line: 778
   org.eclipse.persistence.internal.jpa.EntityManagerImpl.find line: 671
   org.eclipse.persistence.internal.jpa.EntityManagerImpl.find line: 543
   br.com.simfreteV1.broker.TabelaBroker.getTabelasDestino line: 1782
   ...

and the other thread that is blocked:

Stack Trace
http-nio-8088-exec-34 [190] (WAITING)
   java.lang.Object.wait line: not available [native method]
   java.lang.Object.wait line: 485
org.eclipse.persistence.internal.helper.ConcurrencyManager.acquire line: 94
org.eclipse.persistence.internal.identitymaps.CacheKey.acquire line: 132 org.eclipse.persistence.internal.identitymaps.AbstractIdentityMap.acquireLock line: 122 org.eclipse.persistence.internal.identitymaps.IdentityMapManager.acquireLock line: 150 org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock line: 93 org.eclipse.persistence.internal.sessions.IdentityMapAccessor.acquireLock line: 84 org.eclipse.persistence.internal.sessions.AbstractSession.retrieveCacheKey line: 4803 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 777 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 607 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 564 org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject line: 777 org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery line: 462 org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery line: 1150
   org.eclipse.persistence.queries.DatabaseQuery.execute line: 852
   org.eclipse.persistence.queries.ObjectLevelReadQuery.execute line: 1109
   org.eclipse.persistence.queries.ReadObjectQuery.execute line: 421
org.eclipse.persistence.internal.sessions.AbstractSession.internalExecuteQuery line: 2946 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1602 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1584 org.eclipse.persistence.internal.indirection.NoIndirectionPolicy.valueFromQuery line: 323 org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRowInternal line: 2135 org.eclipse.persistence.mappings.OneToOneMapping.valueFromRowInternal line: 1716 org.eclipse.persistence.mappings.ForeignReferenceMapping.valueFromRow line: 2024 org.eclipse.persistence.mappings.ForeignReferenceMapping.readFromRowIntoObject line: 1369 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildAttributesIntoObject line: 448 org.eclipse.persistence.internal.descriptors.ObjectBuilder.refreshObjectIfRequired line: 3673 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 831 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally line: 719 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObjectInUnitOfWork line: 672 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 605 org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildObject line: 564 org.eclipse.persistence.queries.ObjectLevelReadQuery.buildObject line: 777 org.eclipse.persistence.queries.ReadObjectQuery.registerResultInUnitOfWork line: 787 org.eclipse.persistence.queries.ReadObjectQuery.executeObjectLevelReadQuery line: 460 org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery line: 1150
   org.eclipse.persistence.queries.DatabaseQuery.execute line: 852
   org.eclipse.persistence.queries.ObjectLevelReadQuery.execute line: 1109
   org.eclipse.persistence.queries.ReadObjectQuery.execute line: 421
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork line: 1197 org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery line: 2875 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1602 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1584 org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery line: 1549 org.eclipse.persistence.internal.jpa.QueryImpl.executeReadQuery line: 231
   org.eclipse.persistence.internal.jpa.QueryImpl.getResultList line: 403
br.com.simfreteV1.broker.DocumentoTransporteBroker.getDocumentoTransporte line: 457
   ...



Edson


Back to the top