Search in sources :

Example 1 with DynamicTypeBuilder

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

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

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

use of org.eclipse.persistence.dynamic.DynamicTypeBuilder 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 5 with DynamicTypeBuilder

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

Aggregations

DynamicTypeBuilder (org.eclipse.persistence.dynamic.DynamicTypeBuilder)27 DynamicClassLoader (org.eclipse.persistence.dynamic.DynamicClassLoader)26 BeforeClass (org.junit.BeforeClass)22 DynamicHelper (org.eclipse.persistence.dynamic.DynamicHelper)14 JPADynamicHelper (org.eclipse.persistence.jpa.dynamic.JPADynamicHelper)10 JPADynamicTypeBuilder (org.eclipse.persistence.jpa.dynamic.JPADynamicTypeBuilder)10 TableSequence (org.eclipse.persistence.sequencing.TableSequence)4 DynamicEntity (org.eclipse.persistence.dynamic.DynamicEntity)3 DynamicType (org.eclipse.persistence.dynamic.DynamicType)3 NativeSequence (org.eclipse.persistence.sequencing.NativeSequence)2 UnaryTableSequence (org.eclipse.persistence.sequencing.UnaryTableSequence)2 DatabaseSession (org.eclipse.persistence.sessions.DatabaseSession)2 Session (org.eclipse.persistence.sessions.Session)2 Test (org.junit.Test)2 EntityTransaction (jakarta.persistence.EntityTransaction)1 RollbackException (jakarta.persistence.RollbackException)1 Map (java.util.Map)1 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)1 DynamicEnumBuilder (org.eclipse.persistence.dynamic.DynamicEnumBuilder)1 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)1