Search in sources :

Example 91 with UnitOfWorkImpl

use of org.eclipse.persistence.internal.sessions.UnitOfWorkImpl in project eclipselink by eclipse-ee4j.

the class EntityManagerImpl method mergeInternal.

/**
 * Merge the state of the given entity into the current persistence context,
 * using the unqualified class name as the entity name.
 *
 * @return the instance that the state was merged to
 * @throws IllegalArgumentException
 *             if given Object is not an entity or is a removed entity
 */
protected Object mergeInternal(Object entity) {
    if (entity == null) {
        throw new IllegalArgumentException(ExceptionLocalization.buildMessage("not_an_entity", new Object[] { null }));
    }
    Object merged = null;
    UnitOfWorkImpl context = getActivePersistenceContext(checkForTransaction(false));
    try {
        merged = context.mergeCloneWithReferences(entity, MergeManager.CASCADE_BY_MAPPING, true);
    } catch (org.eclipse.persistence.exceptions.OptimisticLockException ole) {
        throw new jakarta.persistence.OptimisticLockException(ole);
    }
    return merged;
}
Also used : UnitOfWorkImpl(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl) OptimisticLockException(jakarta.persistence.OptimisticLockException)

Example 92 with UnitOfWorkImpl

use of org.eclipse.persistence.internal.sessions.UnitOfWorkImpl in project eclipselink by eclipse-ee4j.

the class BeanValidationListener method aboutToUpdate.

@Override
public void aboutToUpdate(DescriptorEvent event) {
    Object source = event.getSource();
    UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl) event.getSession();
    // Do not perform preUpdate validation for such objects as preRemove would have already been called.
    if (!unitOfWork.isObjectDeleted(source)) {
        validateOnCallbackEvent(event, "preUpdate", groupPreUpdate);
    }
}
Also used : UnitOfWorkImpl(org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)

Aggregations

UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)92 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)21 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)19 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)18 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)15 EntityManager (jakarta.persistence.EntityManager)14 InvalidObject (org.eclipse.persistence.internal.helper.InvalidObject)11 JpaEntityManager (org.eclipse.persistence.jpa.JpaEntityManager)9 Vector (java.util.Vector)8 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)8 Department (org.eclipse.persistence.testing.models.jpa.advanced.Department)8 CacheKey (org.eclipse.persistence.internal.identitymaps.CacheKey)7 EntityManagerImpl (org.eclipse.persistence.internal.jpa.EntityManagerImpl)7 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)7 DatabaseException (org.eclipse.persistence.exceptions.DatabaseException)6 UnitOfWorkChangeSet (org.eclipse.persistence.internal.sessions.UnitOfWorkChangeSet)6 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)5 BigDecimal (java.math.BigDecimal)5 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)5 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)5