Search in sources :

Example 1 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class PreBeginTransactionFailureTest method test.

@Override
public void test() {
    Employee emp = new Employee();
    Employee empCopy = (Employee) uow.registerObject(emp);
    empCopy.setFirstName("A");
    try {
        uow.commit();
    } catch (Exception ex) {
        exception = ex;
    }
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Example 2 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class RollbackObjectsTest method test.

@Override
public void test() {
    org.eclipse.persistence.sessions.Session hs = getSession().acquireHistoricalSession(pastTime);
    pastObjects = hs.readAllObjects(domainClass);
    // getSession().getProject().checkDatabaseForDoesExist();
    Vector currentProjects = getSession().readAllObjects(Project.class);
    for (Enumeration enumtr = currentProjects.elements(); enumtr.hasMoreElements(); ) {
        ((Project) enumtr.nextElement()).getTeamLeader();
    }
    UnitOfWork uow = getSession().acquireUnitOfWork();
    for (Enumeration enumtr = pastObjects.elements(); enumtr.hasMoreElements(); ) {
        Employee emp = (Employee) enumtr.nextElement();
        emp.getProjects();
        for (Enumeration proj = emp.getProjects().elements(); proj.hasMoreElements(); ) {
            ((Project) proj.nextElement()).getTeamLeader();
        }
        emp.getAddress();
    }
    for (Enumeration enumtr = pastObjects.elements(); enumtr.hasMoreElements(); ) {
        Employee emp = (Employee) enumtr.nextElement();
        uow.registerObject(emp);
    }
    Vector pastProjects = hs.readAllObjects(Project.class);
    for (Enumeration enumtr = pastProjects.elements(); enumtr.hasMoreElements(); ) {
        Project project = (Project) enumtr.nextElement();
        uow.registerObject(project);
        uow.deepMergeClone(project);
    }
    // uow.registerAllObjects(pastProjects);
    // clone = uow.deepClone(obj);
    // } else {
    // clone = uow.deepMergeClone(obj);
    // }
    uow.commit();
}
Also used : Project(org.eclipse.persistence.testing.models.employee.domain.Project) UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Example 3 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class GetAllFromIdentityMapTest method test.

/**
 * Test case.
 * Verify that {@code ConcurrentModificationException} is not thrown from {@code IdentityMapManager}
 * during 2nd query execution when objects are already in the cache.
 */
@Override
public void test() throws Throwable {
    Vector<Employee> employees = (Vector<Employee>) uow.executeQuery(query);
    assertFalse(employees.isEmpty());
    for (Employee employee : employees) {
        assertEquals("Bob", employee.getManager().getFirstName());
    }
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) Vector(java.util.Vector)

Example 4 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class InsertWeakIdentityMapTest method test.

@Override
public void test() {
    for (int index = 0; index < (identityMapSize * 2); index++) {
        Employee obj = new Employee();
        InsertObjectQuery query = new InsertObjectQuery(obj);
        getAbstractSession().beginTransaction();
        getSession().executeQuery(query);
        getAbstractSession().rollbackTransaction();
        System.gc();
    }
    System.gc();
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee) InsertObjectQuery(org.eclipse.persistence.queries.InsertObjectQuery)

Example 5 with Employee

use of org.eclipse.persistence.testing.models.employee.domain.Employee in project eclipselink by eclipse-ee4j.

the class InsertOverflowTest method test.

@Override
public void test() {
    for (int index = 0; index < (originalMaxSize * 10); index++) {
        Employee employee = new Employee();
        java.math.BigDecimal id = new java.math.BigDecimal((double) index * 101);
        java.util.Vector primaryKeys = new java.util.Vector();
        employee.setId(id);
        employee.setFirstName("Mr. " + id);
        primaryKeys.addElement(id);
        cache.put(primaryKeys, employee, null, 0);
    }
}
Also used : Employee(org.eclipse.persistence.testing.models.employee.domain.Employee)

Aggregations

Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)220 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)79 TestErrorException (org.eclipse.persistence.testing.framework.TestErrorException)52 ExpressionBuilder (org.eclipse.persistence.expressions.ExpressionBuilder)40 Vector (java.util.Vector)34 ReadObjectQuery (org.eclipse.persistence.queries.ReadObjectQuery)32 SmallProject (org.eclipse.persistence.testing.models.employee.domain.SmallProject)29 Address (org.eclipse.persistence.testing.models.employee.domain.Address)24 PhoneNumber (org.eclipse.persistence.testing.models.employee.domain.PhoneNumber)22 Expression (org.eclipse.persistence.expressions.Expression)21 LargeProject (org.eclipse.persistence.testing.models.employee.domain.LargeProject)18 UnitOfWorkImpl (org.eclipse.persistence.internal.sessions.UnitOfWorkImpl)16 TestSuite (org.eclipse.persistence.testing.framework.TestSuite)15 PopulationManager (org.eclipse.persistence.tools.schemaframework.PopulationManager)15 ReadAllQuery (org.eclipse.persistence.queries.ReadAllQuery)14 Project (org.eclipse.persistence.testing.models.employee.domain.Project)14 EmployeePopulator (org.eclipse.persistence.testing.models.employee.domain.EmployeePopulator)11 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)9 ValidationException (org.eclipse.persistence.exceptions.ValidationException)9 EmploymentPeriod (org.eclipse.persistence.testing.models.employee.domain.EmploymentPeriod)9