use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeCompositeKeyTestSuite method createSimpleInstance.
@Override
public DynamicEntity createSimpleInstance(Session session, int id) {
DynamicType simpleEntityType = dynamicHelper.getType("Simple");
Assert.assertNotNull(simpleEntityType);
DynamicEntity simpleInstance = simpleEntityType.newDynamicEntity();
simpleInstance.set("id1", id);
simpleInstance.set("id2", id);
simpleInstance.set("value2", true);
ReportQuery countQuery = dynamicHelper.newReportQuery("Simple", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
assertEquals(0, ((Number) session.executeQuery(countQuery)).intValue());
UnitOfWork uow = session.acquireUnitOfWork();
uow.registerNewObject(simpleInstance);
uow.commit();
assertEquals(1, ((Number) session.executeQuery(countQuery)).intValue());
DynamicEntity foundEntity = find(dynamicHelper, session, 1);
assertNotNull(foundEntity);
assertEquals(simpleInstance.<Integer>get("id1"), foundEntity.<Integer>get("id1"));
assertEquals(simpleInstance.<Integer>get("id2"), foundEntity.<Integer>get("id2"));
assertEquals(simpleInstance.<String>get("value1"), foundEntity.<String>get("value1"));
assertEquals(simpleInstance.<Boolean>get("value2"), foundEntity.<Boolean>get("value2"));
return simpleInstance;
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeTestSuite method invalidDirectMappingSet_id.
@Test(expected = DynamicException.class)
public void invalidDirectMappingSet_id() throws Exception {
DynamicType type = dynamicHelper.getType("Simple");
DynamicEntity entity = type.newDynamicEntity();
entity.set("id", 1l);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypeTestSuite method verifyDefaultValuesFromEntityType.
@Test
public void verifyDefaultValuesFromEntityType() throws Exception {
DynamicType type = dynamicHelper.getType("Simple");
assertNotNull(type);
DynamicEntity simpleInstance = type.newDynamicEntity();
assertDefaultValues(simpleInstance);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_OneToOne method createSimpleA.
@Test
public void createSimpleA() {
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
DynamicEntity simpleInstance = simpleTypeA.newDynamicEntity();
simpleInstance.set("id", 1);
simpleInstance.set("value1", "A1");
UnitOfWork uow = session.acquireUnitOfWork();
uow.registerNewObject(simpleInstance);
uow.commit();
ReportQuery countQuery = dynamicHelper.newReportQuery("SimpleA", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
int simpleCount = ((Number) session.executeQuery(countQuery)).intValue();
Assert.assertEquals(1, simpleCount);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_OneToOne method createSimpleB.
@Test
public void createSimpleB() {
DynamicType simpleTypeB = dynamicHelper.getType("SimpleB");
Assert.assertNotNull(simpleTypeB);
DynamicEntity simpleInstance = simpleTypeB.newDynamicEntity();
simpleInstance.set("id", 1);
simpleInstance.set("value1", "B1");
UnitOfWork uow = session.acquireUnitOfWork();
uow.registerNewObject(simpleInstance);
uow.commit();
ReportQuery countQuery = dynamicHelper.newReportQuery("SimpleB", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
int simpleCount = ((Number) session.executeQuery(countQuery)).intValue();
Assert.assertEquals(1, simpleCount);
}
Aggregations