Search in sources :

Example 1 with EclipseLinkException

use of org.eclipse.persistence.exceptions.EclipseLinkException in project eclipselink by eclipse-ee4j.

the class UnitOfWorkImpl method validateObjectSpace.

/**
 * ADVANCED:
 * This can be used to help debugging an object-space corruption.
 * An object-space corruption is when your application has incorrectly related a clone to an original object.
 * This method will validate that all registered objects are in a correct state and throw
 * an error if not,  it will contain the full stack of object references in the error message.
 * If you call this method after each register or change you perform it will pin-point where the error was made.
 */
@Override
public void validateObjectSpace() {
    log(SessionLog.FINER, SessionLog.TRANSACTION, "validate_object_space");
    // This define an inner class for process the iteration operation, don't be scared, its just an inner class.
    DescriptorIterator iterator = new DescriptorIterator() {

        @Override
        public void iterate(Object object) {
            try {
                if (isClassReadOnly(object.getClass(), getCurrentDescriptor())) {
                    setShouldBreak(true);
                    return;
                } else {
                    getBackupClone(object, getCurrentDescriptor());
                }
            } catch (EclipseLinkException exception) {
                log(SessionLog.FINEST, SessionLog.TRANSACTION, "stack_of_visited_objects_that_refer_to_the_corrupt_object", getVisitedStack());
                log(SessionLog.FINER, SessionLog.TRANSACTION, "corrupt_object_referenced_through_mapping", getCurrentMapping());
                throw exception;
            }
        }
    };
    iterator.setSession(this);
    for (Iterator clonesEnum = getCloneMapping().keySet().iterator(); clonesEnum.hasNext(); ) {
        iterator.startIterationOn(clonesEnum.next());
    }
}
Also used : DescriptorIterator(org.eclipse.persistence.internal.descriptors.DescriptorIterator) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException) Iterator(java.util.Iterator) DescriptorIterator(org.eclipse.persistence.internal.descriptors.DescriptorIterator)

Example 2 with EclipseLinkException

use of org.eclipse.persistence.exceptions.EclipseLinkException in project eclipselink by eclipse-ee4j.

the class BidirectionWithHashtableTest method test.

@Override
public void test() {
    try {
        getSession().setIntegrityChecker(new IntegrityChecker());
        getSession().getIntegrityChecker().dontCatchExceptions();
        ((DatabaseSession) getSession()).addDescriptor(descriptor());
    } catch (EclipseLinkException exception) {
        caughtException = exception;
    }
}
Also used : IntegrityChecker(org.eclipse.persistence.exceptions.IntegrityChecker) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException)

Example 3 with EclipseLinkException

use of org.eclipse.persistence.exceptions.EclipseLinkException in project eclipselink by eclipse-ee4j.

the class ForeignKeysDefinedIncorrectlyTest method test.

@Override
public void test() {
    try {
        getSession().setIntegrityChecker(new IntegrityChecker());
        getSession().getIntegrityChecker().dontCatchExceptions();
        ((DatabaseSession) getSession()).addDescriptor(descriptor());
    } catch (EclipseLinkException exception) {
        caughtException = exception;
    }
}
Also used : IntegrityChecker(org.eclipse.persistence.exceptions.IntegrityChecker) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException)

Example 4 with EclipseLinkException

use of org.eclipse.persistence.exceptions.EclipseLinkException in project eclipselink by eclipse-ee4j.

the class GetMethodReturnsValueHolderTest method test.

@Override
public void test() {
    try {
        getSession().setIntegrityChecker(new IntegrityChecker());
        getSession().getIntegrityChecker().dontCatchExceptions();
        ((DatabaseSession) getSession()).addDescriptor(descriptor());
    } catch (EclipseLinkException exception) {
        caughtException = exception;
    }
}
Also used : IntegrityChecker(org.eclipse.persistence.exceptions.IntegrityChecker) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException)

Example 5 with EclipseLinkException

use of org.eclipse.persistence.exceptions.EclipseLinkException in project eclipselink by eclipse-ee4j.

the class IllegalArgumentWhileGettingValueThruInstanceVariableAccessorTest method test.

@Override
public void test() {
    org.eclipse.persistence.testing.tests.validation.PersonInstanceAccess person = new org.eclipse.persistence.testing.tests.validation.PersonInstanceAccess();
    person.setName("Person");
    Address address = new Address();
    try {
        getSession().setIntegrityChecker(new IntegrityChecker());
        getSession().getIntegrityChecker().dontCatchExceptions();
        ((DatabaseSession) getSession()).addDescriptor(descriptor());
        UnitOfWork uow = getSession().acquireUnitOfWork();
        uow.registerObject(person);
        uow.commit();
        DatabaseMapping dMapping = descriptor().getMappingForAttributeName("p_name");
        DatabaseMapping idMapping = descriptor().getMappingForAttributeName("p_id");
        dMapping.getAttributeAccessor().initializeAttributes(org.eclipse.persistence.testing.tests.validation.PersonInstanceAccess.class);
        dMapping.getAttributeAccessor().initializeAttributes(org.eclipse.persistence.testing.tests.validation.PersonInstanceAccess.class);
        dMapping.getAttributeValueFromObject(address);
    } catch (EclipseLinkException exception) {
        caughtException = exception;
    }
}
Also used : IntegrityChecker(org.eclipse.persistence.exceptions.IntegrityChecker) UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) DatabaseMapping(org.eclipse.persistence.mappings.DatabaseMapping) EclipseLinkException(org.eclipse.persistence.exceptions.EclipseLinkException)

Aggregations

EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)95 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)43 IntegrityChecker (org.eclipse.persistence.exceptions.IntegrityChecker)41 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)10 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)10 SAXParseException (org.xml.sax.SAXParseException)7 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)6 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)4 MalformedURLException (java.net.MalformedURLException)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Expression (org.eclipse.persistence.expressions.Expression)3 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)3 MappingNodeValue (org.eclipse.persistence.internal.oxm.MappingNodeValue)3 NodeValue (org.eclipse.persistence.internal.oxm.NodeValue)3 XPathNode (org.eclipse.persistence.internal.oxm.XPathNode)3 Descriptor (org.eclipse.persistence.internal.oxm.mappings.Descriptor)3 OutputStreamWriter (java.io.OutputStreamWriter)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2