Search in sources :

Example 21 with SchemaManager

use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.

the class JUnitJPQLComplexTestSuite method testSetup.

/**
 * The setup is done as a test, both to record its failure, and to allow execution in the server.
 */
public void testSetup() {
    clearCache();
    // get session to start setup
    DatabaseSession session = JUnitTestCase.getServerSession();
    // create a new EmployeePopulator
    EmployeePopulator employeePopulator = new EmployeePopulator();
    // create a new PartnerLinkPopulator
    PartnerLinkPopulator partnerLinkPopulator = new PartnerLinkPopulator();
    new AdvancedTableCreator().replaceTables(session);
    // initialize the global comparer object
    comparer = new JUnitDomainObjectComparer();
    // set the session for the comparer to use
    comparer.setSession((AbstractSession) session.getActiveSession());
    // Populate the tables
    employeePopulator.buildExamples();
    // Persist the examples in the database
    employeePopulator.persistExample(session);
    // Populate the tables
    partnerLinkPopulator.buildExamples();
    // Persist the examples in the database
    partnerLinkPopulator.persistExample(session);
    new InheritedTableManager().replaceTables(session);
    new DataTypesTableCreator().replaceTables(session);
    // create stored function when database supports it
    if (supportsStoredFunctions()) {
        SchemaManager schema = new SchemaManager(session);
        schema.replaceObject(buildStoredFunction());
    }
    new CompositePKTableCreator().replaceTables(JUnitTestCase.getServerSession());
}
Also used : InheritedTableManager(org.eclipse.persistence.testing.models.jpa.inherited.InheritedTableManager) CompositePKTableCreator(org.eclipse.persistence.testing.models.jpa.advanced.compositepk.CompositePKTableCreator) AdvancedTableCreator(org.eclipse.persistence.testing.models.jpa.advanced.AdvancedTableCreator) EmployeePopulator(org.eclipse.persistence.testing.models.jpa.advanced.EmployeePopulator) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) DataTypesTableCreator(org.eclipse.persistence.testing.models.jpa.datatypes.DataTypesTableCreator) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) PartnerLinkPopulator(org.eclipse.persistence.testing.models.jpa.advanced.PartnerLinkPopulator)

Example 22 with SchemaManager

use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.

the class OracleTIMESTAMPTypeTestSystem method createTables.

@Override
public void createTables(DatabaseSession session) {
    SchemaManager schemaManager = new SchemaManager(session);
    if (session.getPlatform() instanceof Oracle9Platform) {
        schemaManager.replaceObject(TIMESTAMPDirectToFieldTester.tableDefinition(session));
        schemaManager.replaceObject(TIMESTAMPTypeConversionTester.tableDefinition(session));
        schemaManager.replaceObject(CalendarToTSTZWithoutSessionTZTest.tableDefinition(session));
        schemaManager.replaceObject(TIMESTAMPTZOwner.tableDefinition());
        schemaManager.replaceObject(CalendarToTSTZWithBindingTest.tableDefinition());
        schemaManager.replaceObject(CalendarDaylightSavingsTest.tableDefinition());
    }
}
Also used : Oracle9Platform(org.eclipse.persistence.platform.database.oracle.Oracle9Platform) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager)

Example 23 with SchemaManager

use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.

the class EmployeePopulator method persistExample.

public void persistExample(Session session) {
    Vector allObjects = new Vector();
    UnitOfWork unitOfWork = session.acquireUnitOfWork();
    // Disable the read-only classes for model population. Specifically,
    // in this case we want to be able to create EquipmentCode objects.
    unitOfWork.removeAllReadOnlyClasses();
    PopulationManager.getDefaultManager().addAllObjectsForClass(Employee.class, allObjects);
    PopulationManager.getDefaultManager().addAllObjectsForClass(SmallProject.class, allObjects);
    PopulationManager.getDefaultManager().addAllObjectsForClass(LargeProject.class, allObjects);
    PopulationManager.getDefaultManager().addAllObjectsForClass(GoldBuyer.class, allObjects);
    PopulationManager.getDefaultManager().addAllObjectsForClass(PlatinumBuyer.class, allObjects);
    PopulationManager.getDefaultManager().addAllObjectsForClass(EquipmentCode.class, allObjects);
    unitOfWork.registerAllObjects(allObjects);
    unitOfWork.commit();
    if (TestCase.supportsStoredProcedures(session)) {
        SchemaManager schema = new SchemaManager((DatabaseSession) session);
        schema.replaceObject(buildOracleStoredProcedureReadFromAddress((DatabaseSession) session));
        schema.replaceObject(buildOracleStoredProcedureReadInOut((DatabaseSession) session));
    }
    // Force uppercase for Postgres.
    if (session.getPlatform().isPostgreSQL()) {
        session.getLogin().setShouldForceFieldNamesToUpperCase(true);
    }
}
Also used : UnitOfWork(org.eclipse.persistence.sessions.UnitOfWork) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager)

Example 24 with SchemaManager

use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.

the class EntityTypeFromDescriptor method entityTypeFromDescriptor.

@Test
public void entityTypeFromDescriptor() throws Exception {
    DatabaseSession session = createSession();
    session.login();
    DynamicClassLoader dcl = DynamicClassLoader.lookup(session);
    ClassDescriptor descriptor = buildMyEntityDescriptor();
    assertFalse(descriptor.isAggregateDescriptor());
    DynamicType entityType = new DynamicTypeBuilder(dcl, descriptor, null).getType();
    MyEntity.DPM.setType(entityType);
    assertFalse(descriptor.isAggregateDescriptor());
    assertEquals(MyEntity.class, entityType.getJavaClass());
    session.addDescriptor(entityType.getDescriptor());
    new SchemaManager(session).replaceDefaultTables();
    DynamicEntity entity = entityType.newDynamicEntity();
    entity.set("id", 1);
    entity.set("name", "Name");
    session.insertObject(entity);
    session.logout();
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) DatabaseSession(org.eclipse.persistence.sessions.DatabaseSession) DynamicEntity(org.eclipse.persistence.dynamic.DynamicEntity) DynamicType(org.eclipse.persistence.dynamic.DynamicType) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) DynamicTypeBuilder(org.eclipse.persistence.dynamic.DynamicTypeBuilder) Test(org.junit.Test)

Example 25 with SchemaManager

use of org.eclipse.persistence.tools.schemaframework.SchemaManager in project eclipselink by eclipse-ee4j.

the class EmployeeCustomSQLMWIntegrationSystem method createTables.

// build your owner stored procedure rather than those inherited if necessary.
// schema.replaceObject(buildOracleStoredProcedureForProjectXML());
@Override
public void createTables(DatabaseSession session) {
    super.createTables(session);
    org.eclipse.persistence.internal.databaseaccess.DatabasePlatform platform = session.getLogin().getPlatform();
    SchemaManager schema = new SchemaManager((session));
    if (platform.isOracle()) {
    }
}
Also used : SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager)

Aggregations

SchemaManager (org.eclipse.persistence.tools.schemaframework.SchemaManager)40 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)17 UnitOfWork (org.eclipse.persistence.sessions.UnitOfWork)9 Vector (java.util.Vector)4 DatabasePlatform (org.eclipse.persistence.internal.databaseaccess.DatabasePlatform)4 StoredProcedureDefinition (org.eclipse.persistence.tools.schemaframework.StoredProcedureDefinition)4 EntityManager (jakarta.persistence.EntityManager)3 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)3 EntityManagerFactoryProvider.getConfigPropertyAsString (org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.getConfigPropertyAsString)3 DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)3 DatabasePlatform (org.eclipse.persistence.platform.database.DatabasePlatform)3 SessionBroker (org.eclipse.persistence.sessions.broker.SessionBroker)3 Employee (org.eclipse.persistence.testing.models.employee.domain.Employee)3 DynamicClassLoader (org.eclipse.persistence.dynamic.DynamicClassLoader)2 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)2 DynamicHelper (org.eclipse.persistence.dynamic.DynamicHelper)2 DynamicType (org.eclipse.persistence.dynamic.DynamicType)2 Platform (org.eclipse.persistence.internal.databaseaccess.Platform)2 EntityManagerImpl (org.eclipse.persistence.internal.jpa.EntityManagerImpl)2 ManyToManyMapping (org.eclipse.persistence.mappings.ManyToManyMapping)2