Search in sources :

Example 6 with DynamicClassLoader

use of org.eclipse.persistence.dynamic.DynamicClassLoader in project eclipselink by eclipse-ee4j.

the class SimpleTypeTestSuite method setUp.

@BeforeClass
public static void setUp() {
    session = createSession();
    dynamicHelper = new DynamicHelper(session);
    DynamicClassLoader dcl = dynamicHelper.getDynamicClassLoader();
    Class<?> javaType = dcl.createDynamicClass("simple.Simple");
    DynamicTypeBuilder typeBuilder = new DynamicTypeBuilder(javaType, null, "SIMPLE_TYPE");
    typeBuilder.setPrimaryKeyFields("SID");
    typeBuilder.addDirectMapping("id", int.class, "SID");
    typeBuilder.addDirectMapping("value1", String.class, "VAL_1");
    typeBuilder.addDirectMapping("value2", boolean.class, "VAL_2");
    typeBuilder.addDirectMapping("value3", Calendar.class, "VAL_3");
    typeBuilder.addDirectMapping("value4", Character.class, "VAL_4");
    dynamicHelper.addTypes(true, false, typeBuilder.getType());
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) DynamicHelper(org.eclipse.persistence.dynamic.DynamicHelper) DynamicTypeBuilder(org.eclipse.persistence.dynamic.DynamicTypeBuilder) BeforeClass(org.junit.BeforeClass)

Example 7 with DynamicClassLoader

use of org.eclipse.persistence.dynamic.DynamicClassLoader in project eclipselink by eclipse-ee4j.

the class SimpleTypes_OneToOne method setUp.

@BeforeClass
public static void setUp() {
    session = createSession();
    // force logging level
    session.setLogLevel(SessionLog.FINE);
    dynamicHelper = new DynamicHelper(session);
    DynamicClassLoader dcl = dynamicHelper.getDynamicClassLoader();
    Class<?> simpleTypeB = dcl.createDynamicClass("simple.mappings.SimpleB");
    DynamicTypeBuilder bFactory = new DynamicTypeBuilder(simpleTypeB, null, "SIMPLE_TYPE_B");
    bFactory.setPrimaryKeyFields("SID");
    bFactory.addDirectMapping("id", int.class, "SID");
    bFactory.addDirectMapping("value1", String.class, "VAL_1");
    Class<?> simpleTypeA = dcl.createDynamicClass("simple.mappings.SimpleA");
    DynamicTypeBuilder aFactory = new DynamicTypeBuilder(simpleTypeA, null, "SIMPLE_TYPE_A");
    aFactory.setPrimaryKeyFields("SID");
    aFactory.addDirectMapping("id", int.class, "SID");
    aFactory.addDirectMapping("value1", String.class, "VAL_1");
    aFactory.addOneToOneMapping("b", bFactory.getType(), "B_FK");
    dynamicHelper.addTypes(true, true, aFactory.getType(), bFactory.getType());
    qTracker = QuerySQLTracker.install(session);
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) DynamicHelper(org.eclipse.persistence.dynamic.DynamicHelper) DynamicTypeBuilder(org.eclipse.persistence.dynamic.DynamicTypeBuilder) BeforeClass(org.junit.BeforeClass)

Example 8 with DynamicClassLoader

use of org.eclipse.persistence.dynamic.DynamicClassLoader in project eclipselink by eclipse-ee4j.

the class EmployeeProjectTestSuite method setUp.

@BeforeClass
public static void setUp() {
    DynamicClassLoader dcl = new DynamicClassLoader(EmployeeProjectTestSuite.class.getClassLoader());
    Project project = null;
    try {
        project = DynamicTypeBuilder.loadDynamicProject(PROJECT_XML, createLogin(), dcl);
    } catch (IOException e) {
        // e.printStackTrace();
        fail("cannot find employee-project.xml");
    }
    session = project.createDatabaseSession();
    if (SessionLog.OFF == logLevel) {
        session.dontLogMessages();
    } else {
        session.setLogLevel(logLevel);
    }
    dynamicHelper = new DynamicHelper(session);
    session.login();
    new SchemaManager(session).replaceDefaultTables();
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) Project(org.eclipse.persistence.sessions.Project) DynamicHelper(org.eclipse.persistence.dynamic.DynamicHelper) IOException(java.io.IOException) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) BeforeClass(org.junit.BeforeClass)

Example 9 with DynamicClassLoader

use of org.eclipse.persistence.dynamic.DynamicClassLoader in project eclipselink by eclipse-ee4j.

the class InvalidConfig method invalidResource.

@Test(expected = XMLMarshalException.class)
public void invalidResource() throws Exception {
    DynamicClassLoader dynamicClassLoader = new DynamicClassLoader(InvalidConfig.class.getClassLoader());
    InputStream is = dynamicClassLoader.getResourceAsStream(INVALID_PROJECT_XML);
    DynamicTypeBuilder.loadDynamicProject(is, new DatabaseLogin(), dynamicClassLoader);
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) DatabaseLogin(org.eclipse.persistence.sessions.DatabaseLogin) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Test(org.junit.Test)

Example 10 with DynamicClassLoader

use of org.eclipse.persistence.dynamic.DynamicClassLoader in project eclipselink by eclipse-ee4j.

the class SimpleMapProject method setUp.

@BeforeClass
public static void setUp() {
    DynamicClassLoader dcl = new DynamicClassLoader(SimpleMapProject.class.getClassLoader());
    Project project = null;
    try {
        project = DynamicTypeBuilder.loadDynamicProject(PROJECT_XML, createLogin(), dcl);
    } catch (IOException e) {
        // e.printStackTrace();
        fail("cannot find simple-map-project.xml");
    }
    session = project.createDatabaseSession();
    if (SessionLog.OFF == logLevel) {
        session.dontLogMessages();
    } else {
        session.setLogLevel(logLevel);
    }
    dynamicHelper = new DynamicHelper(session);
    session.login();
    new DynamicSchemaManager(session).createTables();
}
Also used : DynamicClassLoader(org.eclipse.persistence.dynamic.DynamicClassLoader) Project(org.eclipse.persistence.sessions.Project) DynamicHelper(org.eclipse.persistence.dynamic.DynamicHelper) DynamicSchemaManager(org.eclipse.persistence.tools.schemaframework.DynamicSchemaManager) IOException(java.io.IOException) BeforeClass(org.junit.BeforeClass)

Aggregations

DynamicClassLoader (org.eclipse.persistence.dynamic.DynamicClassLoader)58 BeforeClass (org.junit.BeforeClass)27 DynamicTypeBuilder (org.eclipse.persistence.dynamic.DynamicTypeBuilder)26 DynamicHelper (org.eclipse.persistence.dynamic.DynamicHelper)17 Test (org.junit.Test)17 JPADynamicHelper (org.eclipse.persistence.jpa.dynamic.JPADynamicHelper)15 JPADynamicTypeBuilder (org.eclipse.persistence.jpa.dynamic.JPADynamicTypeBuilder)13 HashMap (java.util.HashMap)7 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)6 DynamicType (org.eclipse.persistence.dynamic.DynamicType)5 IOException (java.io.IOException)4 TableSequence (org.eclipse.persistence.sequencing.TableSequence)4 EntityManager (jakarta.persistence.EntityManager)3 EntityManagerFactory (jakarta.persistence.EntityManagerFactory)3 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)3 Project (org.eclipse.persistence.sessions.Project)3 EclipseLinkClassWriter (org.eclipse.persistence.dynamic.EclipseLinkClassWriter)2 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)2