use of org.eclipse.persistence.jpa.dynamic.JPADynamicHelper in project eclipselink by eclipse-ee4j.
the class PersistenceContext method newEntity.
/**
* A convenience method to create a new dynamic entity of the given type
*/
public DynamicEntity newEntity(Map<String, String> tenantId, String type) {
JPADynamicHelper helper = new JPADynamicHelper(getEmf());
DynamicEntity entity;
try {
entity = helper.newDynamicEntity(type);
} catch (IllegalArgumentException e) {
ClassDescriptor descriptor = getDescriptor(type);
if (descriptor != null) {
DynamicType jaxbType = (DynamicType) descriptor.getProperty(DynamicType.DESCRIPTOR_PROPERTY);
if (jaxbType != null) {
return jaxbType.newDynamicEntity();
}
}
JPARSLogger.exception(getSessionLog(), "exception_thrown_while_creating_dynamic_entity", new Object[] { type }, e);
throw e;
}
return entity;
}
use of org.eclipse.persistence.jpa.dynamic.JPADynamicHelper in project eclipselink by eclipse-ee4j.
the class EmployeeUpdateTestSuite method setUp.
@BeforeClass
public static void setUp() throws Exception {
emf = DynamicTestHelper.createEMF(DYNAMIC_PERSISTENCE_NAME);
helper = new JPADynamicHelper(emf);
deSystem = DynamicEmployeeSystem.buildProject(helper);
serverSession = JpaHelper.getServerSession(emf);
deSystem.populate(helper, emf.createEntityManager());
serverSession.getIdentityMapAccessor().initializeAllIdentityMaps();
qTracker = QuerySQLTracker.install(serverSession);
// QuerySQLTracker only works if logging is set to FINE
serverSession.setLogLevel(SessionLog.FINE);
}
use of org.eclipse.persistence.jpa.dynamic.JPADynamicHelper in project eclipselink by eclipse-ee4j.
the class TableSequencingTestSuite method setUp.
@BeforeClass
public static void setUp() {
emf = DynamicTestHelper.createEMF(DYNAMIC_PERSISTENCE_NAME);
helper = new JPADynamicHelper(emf);
DynamicClassLoader dcl = helper.getDynamicClassLoader();
TableSequence sequence = new TableSequence();
sequence.setTableName("TEST_SEQ");
sequence.setCounterFieldName("SEQ_VALUE");
sequence.setNameFieldName("SEQ_NAME");
sequence.setPreallocationSize(5);
helper.getSession().getProject().getLogin().setDefaultSequence(sequence);
sequence.onConnect(helper.getSession().getPlatform());
Class<?> javaType = dcl.createDynamicClass("model.sequencing." + ENTITY_TYPE);
DynamicTypeBuilder typeBuilder = new JPADynamicTypeBuilder(javaType, null, TABLE_NAME);
typeBuilder.setPrimaryKeyFields("SID");
typeBuilder.addDirectMapping("id", int.class, "SID");
typeBuilder.addDirectMapping("value1", String.class, "VAL_1");
typeBuilder.configureSequencing(sequence, ENTITY_TYPE + "_SEQ", "SID");
helper.addTypes(true, true, typeBuilder.getType());
}
use of org.eclipse.persistence.jpa.dynamic.JPADynamicHelper in project eclipselink by eclipse-ee4j.
the class SimpleTypes_ManyToMany method setUp.
@BeforeClass
public static void setUp() {
emf = DynamicTestHelper.createEMF(DYNAMIC_PERSISTENCE_NAME);
helper = new JPADynamicHelper(emf);
DynamicClassLoader dcl = helper.getDynamicClassLoader();
Class<?> simpleTypeA = dcl.createDynamicClass("model.SimpleA");
DynamicTypeBuilder aFactory = new JPADynamicTypeBuilder(simpleTypeA, null, "SIMPLE_TYPE_A");
aFactory.setPrimaryKeyFields("SID");
Class<?> simpleTypeB = dcl.createDynamicClass("model.SimpleB");
DynamicTypeBuilder bFactory = new JPADynamicTypeBuilder(simpleTypeB, null, "SIMPLE_TYPE_B");
bFactory.setPrimaryKeyFields("SID");
bFactory.addDirectMapping("id", int.class, "SID");
bFactory.addDirectMapping("value1", String.class, "VAL_1");
bFactory.addOneToOneMapping("a", aFactory.getType(), "A_FK");
aFactory.addDirectMapping("id", int.class, "SID");
aFactory.addDirectMapping("value1", String.class, "VAL_1");
aFactory.addManyToManyMapping("b", bFactory.getType(), "SIMPLE_A_B");
helper.addTypes(true, true, aFactory.getType(), bFactory.getType());
}
use of org.eclipse.persistence.jpa.dynamic.JPADynamicHelper in project eclipselink by eclipse-ee4j.
the class SimpleTypeCompositeKeyTestSuite method setUp.
@BeforeClass
public static void setUp() throws Exception {
emf = DynamicTestHelper.createEMF(DYNAMIC_PERSISTENCE_NAME);
helper = new JPADynamicHelper(emf);
DynamicClassLoader dcl = helper.getDynamicClassLoader();
Class<?> javaType = dcl.createDynamicClass("model.Simple");
DynamicTypeBuilder typeBuilder = new JPADynamicTypeBuilder(javaType, null, "SIMPLE_TYPE");
typeBuilder.setPrimaryKeyFields("SID1", "SID2");
typeBuilder.addDirectMapping("id1", int.class, "SID1");
typeBuilder.addDirectMapping("id2", int.class, "SID2");
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");
helper.addTypes(true, true, typeBuilder.getType());
simpleType = helper.getType("Simple");
}
Aggregations