Search in sources :

Example 1 with DynamicHelper

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

the class SimpleTypes_MultiTable method setUp.

@BeforeClass
public static void setUp() {
    session = createSession();
    dynamicHelper = new DynamicHelper(session);
    DynamicClassLoader dcl = dynamicHelper.getDynamicClassLoader();
    Class<?> simpleTypeA = dcl.createDynamicClass("simple.mappings.SimpleA");
    DynamicTypeBuilder typeBuilder = new DynamicTypeBuilder(simpleTypeA, null, "SIMPLE_TYPE_A", "SIMPLE_TYPE_B", "SIMPLE_TYPE_C");
    typeBuilder.setPrimaryKeyFields("SIMPLE_TYPE_A.SID");
    typeBuilder.addDirectMapping("id", int.class, "SIMPLE_TYPE_A.SID");
    typeBuilder.addDirectMapping("value1", String.class, "SIMPLE_TYPE_A.VAL_1");
    typeBuilder.addDirectMapping("value2", boolean.class, "SIMPLE_TYPE_B.VAL_2");
    typeBuilder.addDirectMapping("value3", String.class, "SIMPLE_TYPE_B.VAL_3");
    typeBuilder.addDirectMapping("value4", double.class, "SIMPLE_TYPE_C.VAL_4");
    typeBuilder.addDirectMapping("value5", String.class, "SIMPLE_TYPE_C.VAL_5");
    dynamicHelper.addTypes(true, true, 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 2 with DynamicHelper

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

the class SimpleTypes_OneToMany method setUp.

@BeforeClass
public static void setUp() {
    session = createSession();
    dynamicHelper = new DynamicHelper(session);
    DynamicClassLoader dcl = dynamicHelper.getDynamicClassLoader();
    // Create Dynamic Classes
    Class<?> simpleTypeA = dcl.createDynamicClass("simple.mappings.SimpleA");
    Class<?> simpleTypeB = dcl.createDynamicClass("simple.mappings.SimpleB");
    // Build dynamic types with mappings
    DynamicTypeBuilder aTypeBuilder = new DynamicTypeBuilder(simpleTypeA, null, "SIMPLE_TYPE_A");
    aTypeBuilder.setPrimaryKeyFields("SID");
    DynamicTypeBuilder bTypeBuilder = new DynamicTypeBuilder(simpleTypeB, null, "SIMPLE_TYPE_B");
    bTypeBuilder.setPrimaryKeyFields("SID");
    bTypeBuilder.addDirectMapping("id", int.class, "SID");
    bTypeBuilder.addDirectMapping("value1", String.class, "VAL_1");
    bTypeBuilder.addOneToOneMapping("a", aTypeBuilder.getType(), "A_FK");
    aTypeBuilder.addDirectMapping("id", int.class, "SID");
    aTypeBuilder.addDirectMapping("value1", String.class, "VAL_1");
    aTypeBuilder.addOneToManyMapping("b", bTypeBuilder.getType(), "A_FK");
    dynamicHelper.addTypes(true, true, aTypeBuilder.getType(), bTypeBuilder.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 3 with DynamicHelper

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

the class SimpleTypes_AggregateObject method setUp.

@BeforeClass
public static void setUp() {
    session = createSession();
    dynamicHelper = new DynamicHelper(session);
    DynamicClassLoader dcl = dynamicHelper.getDynamicClassLoader();
    Class<?> simpleTypeB = dcl.createDynamicClass("simple.mappings.SimpleB");
    DynamicTypeBuilder bTypeBuilder = new DynamicTypeBuilder(simpleTypeB, null);
    bTypeBuilder.addDirectMapping("value2", boolean.class, "VAL_2");
    bTypeBuilder.addDirectMapping("value3", String.class, "VAL_3");
    Class<?> simpleTypeC = dcl.createDynamicClass("simple.mappings.SimpleC");
    DynamicTypeBuilder cTypeBuilder = new DynamicTypeBuilder(simpleTypeC, null);
    cTypeBuilder.addDirectMapping("value4", double.class, "VAL_4");
    cTypeBuilder.addDirectMapping("value5", String.class, "VAL_5");
    Class<?> simpleTypeA = dcl.createDynamicClass("simple.mappings.SimpleA");
    DynamicTypeBuilder aTypeBuilder = new DynamicTypeBuilder(simpleTypeA, null, "SIMPLE_TYPE_A");
    aTypeBuilder.setPrimaryKeyFields("SID");
    aTypeBuilder.addDirectMapping("id", int.class, "SID");
    aTypeBuilder.addDirectMapping("value1", String.class, "VAL_1");
    aTypeBuilder.addAggregateObjectMapping("b", bTypeBuilder.getType(), true);
    aTypeBuilder.addAggregateObjectMapping("c", cTypeBuilder.getType(), false);
    dynamicHelper.addTypes(true, true, aTypeBuilder.getType(), bTypeBuilder.getType(), cTypeBuilder.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 4 with DynamicHelper

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

the class ComicsPopulateAndQueryTestSuite method setUp.

@BeforeClass
public static void setUp() {
    session = ComicsConfigTestSuite.buildComicsSession();
    assertNotNull(session);
    dynamicHelper = new DynamicHelper(session);
    SchemaManager sm = new SchemaManager(session);
    sm.replaceDefaultTables();
    sm.replaceSequences();
}
Also used : DynamicHelper(org.eclipse.persistence.dynamic.DynamicHelper) SchemaManager(org.eclipse.persistence.tools.schemaframework.SchemaManager) BeforeClass(org.junit.BeforeClass)

Example 5 with DynamicHelper

use of org.eclipse.persistence.dynamic.DynamicHelper 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)

Aggregations

DynamicHelper (org.eclipse.persistence.dynamic.DynamicHelper)20 BeforeClass (org.junit.BeforeClass)19 DynamicClassLoader (org.eclipse.persistence.dynamic.DynamicClassLoader)17 DynamicTypeBuilder (org.eclipse.persistence.dynamic.DynamicTypeBuilder)14 IOException (java.io.IOException)3 Project (org.eclipse.persistence.sessions.Project)3 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)2 DynamicType (org.eclipse.persistence.dynamic.DynamicType)2 TableSequence (org.eclipse.persistence.sequencing.TableSequence)2 DynamicSchemaManager (org.eclipse.persistence.tools.schemaframework.DynamicSchemaManager)2 SchemaManager (org.eclipse.persistence.tools.schemaframework.SchemaManager)2 EntityTransaction (jakarta.persistence.EntityTransaction)1 RollbackException (jakarta.persistence.RollbackException)1 DynamicEnumBuilder (org.eclipse.persistence.dynamic.DynamicEnumBuilder)1 JPADynamicHelper (org.eclipse.persistence.jpa.dynamic.JPADynamicHelper)1 JPADynamicTypeBuilder (org.eclipse.persistence.jpa.dynamic.JPADynamicTypeBuilder)1 SessionLog (org.eclipse.persistence.logging.SessionLog)1 NativeSequence (org.eclipse.persistence.sequencing.NativeSequence)1 UnaryTableSequence (org.eclipse.persistence.sequencing.UnaryTableSequence)1 Session (org.eclipse.persistence.sessions.Session)1