Search in sources :

Example 1 with EmployeeProject

use of org.eclipse.persistence.testing.models.employee.relational.EmployeeProject in project eclipselink by eclipse-ee4j.

the class PreBeginTransactionFailureTest method setup.

@Override
public void setup() {
    Project project = new EmployeeProject();
    project.setLogin((DatabaseLogin) getSession().getLogin().clone());
    serverSession = project.createServerSession(1, 1);
    serverSession.setSessionLog(getSession().getSessionLog());
    serverSession.login();
    PreBeginTransactionFailureTest.SessionListener listener = new PreBeginTransactionFailureTest.SessionListener();
    Session clientSession = serverSession.acquireClientSession();
    clientSession.getEventManager().addListener(listener);
    uow = clientSession.acquireUnitOfWork();
}
Also used : EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject) EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)

Example 2 with EmployeeProject

use of org.eclipse.persistence.testing.models.employee.relational.EmployeeProject in project eclipselink by eclipse-ee4j.

the class ProjectXMLDatabaseTableNameTest method test.

@Override
public void test() {
    Project project1 = new EmployeeProject();
    m_tableNameBeforeWrite = project1.getDescriptor(Address.class).getTableName();
    DatabaseTable dbTable = project1.getDescriptor(Address.class).getTable(m_tableNameBeforeWrite);
    dbTable.setName(m_tableNameBeforeWrite);
    dbTable.setTableQualifier(TABLE_NAME_QUALIFIER);
    // Write out the project with changes and read back in again.
    XMLProjectWriter.write(TEMP_FILE, project1);
    Project project2 = XMLProjectReader.read(TEMP_FILE, getClass().getClassLoader());
    m_tableNameAfterWrite = project2.getDescriptor(Address.class).getTable(m_tableNameBeforeWrite).getQualifiedName();
}
Also used : Project(org.eclipse.persistence.sessions.Project) EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject) Address(org.eclipse.persistence.testing.models.employee.domain.Address) DatabaseTable(org.eclipse.persistence.internal.helper.DatabaseTable) EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)

Example 3 with EmployeeProject

use of org.eclipse.persistence.testing.models.employee.relational.EmployeeProject in project eclipselink by eclipse-ee4j.

the class QueryShouldMaintainCacheTest method setup.

@Override
public void setup() {
    project = new EmployeeProject();
    ClassDescriptor descriptor = project.getDescriptors().get(org.eclipse.persistence.testing.models.employee.domain.Employee.class);
    descriptor.disableCacheHits();
    // ReadObjectQuery query = new ReadObjectQuery(Employee.class);
    // descriptor.getQueryManager().addQuery("UndefinedQuery", query);
    ReadObjectQuery query = new ReadObjectQuery(Employee.class);
    query.maintainCache();
    descriptor.getQueryManager().addQuery("TrueQuery", query);
    query = new ReadObjectQuery(Employee.class);
    query.dontMaintainCache();
    descriptor.getQueryManager().addQuery("FalseQuery", query);
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) ReadObjectQuery(org.eclipse.persistence.queries.ReadObjectQuery) EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)

Example 4 with EmployeeProject

use of org.eclipse.persistence.testing.models.employee.relational.EmployeeProject in project eclipselink by eclipse-ee4j.

the class RuntimeCustomSQLQueriesTest method setup.

@Override
protected void setup() {
    // Modify the employee project to use custom SQL queries
    EmployeeProject project = new EmployeeProject();
    ClassDescriptor addressDescriptor = project.getDescriptors().get(Address.class);
    addressDescriptor.getQueryManager().setInsertSQLString(INSERT_SQL);
    addressDescriptor.getQueryManager().setReadObjectSQLString(READ_OBJECT_SQL);
    addressDescriptor.getQueryManager().setReadAllSQLString(READ_ALL_SQL);
    addressDescriptor.getQueryManager().setUpdateSQLString(UPDATE_SQL);
    addressDescriptor.getQueryManager().setDeleteSQLString(DELETE_SQL);
    // write project to an XMLl project file
    XMLProjectWriter.write(PROJECT_FILE, project);
}
Also used : ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)

Example 5 with EmployeeProject

use of org.eclipse.persistence.testing.models.employee.relational.EmployeeProject in project eclipselink by eclipse-ee4j.

the class AddDescriptorsTest method reset.

@Override
public void reset() {
    if (newProjectDescriptor == oldProjectDescriptor) {
        // The test has failed - at least one "old" descriptor is referenced by a new descriptor.
        // To ensure consistency, remove EmployeeSystem interface descriptors first,
        // then add all EmployeeSystem descriptors again
        Iterator<Class<?>> iterator = getSession().getDescriptors().keySet().iterator();
        while (iterator.hasNext()) {
            Class<?> cls = iterator.next();
            String packageName = Helper.getPackageName(cls);
            if (packageName.equals("org.eclipse.persistence.testing.models.employee.interfaces")) {
                getSession().getDescriptors().remove(cls);
            }
        }
        getDatabaseSession().addDescriptors(new EmployeeProject());
    }
}
Also used : EmployeeProject(org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)

Aggregations

EmployeeProject (org.eclipse.persistence.testing.models.employee.relational.EmployeeProject)17 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)8 Project (org.eclipse.persistence.sessions.Project)5 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)4 CollectionMapping (org.eclipse.persistence.mappings.CollectionMapping)2 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)2 Address (org.eclipse.persistence.testing.models.employee.domain.Address)2 PhoneNumber (org.eclipse.persistence.testing.models.employee.domain.PhoneNumber)2 GregorianCalendar (java.util.GregorianCalendar)1 TreeSet (java.util.TreeSet)1 CMPPolicy (org.eclipse.persistence.descriptors.CMPPolicy)1 DescriptorEventAdapter (org.eclipse.persistence.descriptors.DescriptorEventAdapter)1 DescriptorQueryManager (org.eclipse.persistence.descriptors.DescriptorQueryManager)1 PessimisticLockingPolicy (org.eclipse.persistence.descriptors.PessimisticLockingPolicy)1 VersionLockingPolicy (org.eclipse.persistence.descriptors.VersionLockingPolicy)1 AttributeChangeTrackingPolicy (org.eclipse.persistence.descriptors.changetracking.AttributeChangeTrackingPolicy)1 DailyCacheInvalidationPolicy (org.eclipse.persistence.descriptors.invalidation.DailyCacheInvalidationPolicy)1 NoExpiryCacheInvalidationPolicy (org.eclipse.persistence.descriptors.invalidation.NoExpiryCacheInvalidationPolicy)1 TimeToLiveCacheInvalidationPolicy (org.eclipse.persistence.descriptors.invalidation.TimeToLiveCacheInvalidationPolicy)1 DatabaseTable (org.eclipse.persistence.internal.helper.DatabaseTable)1