use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_MultiTable method verifyProperties.
@Test
public void verifyProperties() {
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
assertEquals(6, simpleTypeA.getNumberOfProperties());
assertTrue(simpleTypeA.getPropertiesNames().contains("id"));
assertEquals(int.class, simpleTypeA.getPropertyType("id"));
assertTrue("value1", simpleTypeA.getPropertiesNames().contains("value1"));
assertEquals(String.class, simpleTypeA.getPropertyType("value1"));
assertTrue("value2", simpleTypeA.getPropertiesNames().contains("value2"));
assertEquals(boolean.class, simpleTypeA.getPropertyType("value2"));
assertTrue("value3", simpleTypeA.getPropertiesNames().contains("value3"));
assertEquals(String.class, simpleTypeA.getPropertyType("value3"));
assertTrue("value4", simpleTypeA.getPropertiesNames().contains("value4"));
assertEquals(double.class, simpleTypeA.getPropertyType("value4"));
assertTrue("value5", simpleTypeA.getPropertiesNames().contains("value5"));
assertEquals(String.class, simpleTypeA.getPropertyType("value5"));
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_MultiTable method verifyConfig.
@Test
public void verifyConfig() throws Exception {
ClassDescriptor descriptorA = dynamicHelper.getSession().getClassDescriptorForAlias("SimpleA");
assertNotNull("No descriptor found for alias='SimpleA'", descriptorA);
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
assertNotNull("'SimpleA' EntityType not found", simpleTypeA);
assertEquals(descriptorA, simpleTypeA.getDescriptor());
assertTrue(descriptorA.hasMultipleTables());
assertEquals(3, descriptorA.getTables().size());
DirectToFieldMapping a_id = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("id");
assertEquals(int.class, a_id.getAttributeClassification());
DirectToFieldMapping a_value1 = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("value1");
assertEquals(String.class, a_value1.getAttributeClassification());
DirectToFieldMapping a_value2 = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("value2");
assertEquals(boolean.class, a_value2.getAttributeClassification());
DirectToFieldMapping a_value3 = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("value3");
assertEquals(String.class, a_value3.getAttributeClassification());
DirectToFieldMapping a_value4 = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("value4");
assertEquals(double.class, a_value4.getAttributeClassification());
DirectToFieldMapping a_value5 = (DirectToFieldMapping) descriptorA.getMappingForAttributeName("value5");
assertEquals(String.class, a_value5.getAttributeClassification());
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_MultiTable method verifyChangeTracking.
@Test
public void verifyChangeTracking() {
persistSimpleA();
DynamicType simpleTypeA = dynamicHelper.getType("SimpleA");
Assert.assertNotNull(simpleTypeA);
UnitOfWork uow = session.acquireUnitOfWork();
ReadObjectQuery findQuery = dynamicHelper.newReadObjectQuery("SimpleA");
findQuery.setSelectionCriteria(findQuery.getExpressionBuilder().get("id").equal(1));
DynamicEntityImpl a = (DynamicEntityImpl) uow.executeQuery(findQuery);
assertNotNull(a);
assertNotNull(a._persistence_getPropertyChangeListener());
uow.release();
session.release();
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_OneToMany method removeAwithB_PrivateOwned.
@Test
public void removeAwithB_PrivateOwned() {
createAwithB();
DynamicType simpleAType = dynamicHelper.getType("SimpleA");
((OneToManyMapping) simpleAType.getDescriptor().getMappingForAttributeName("b")).setIsPrivateOwned(true);
UnitOfWork uow = session.acquireUnitOfWork();
ReadObjectQuery findQuery = dynamicHelper.newReadObjectQuery("SimpleA");
findQuery.setSelectionCriteria(findQuery.getExpressionBuilder().get("id").equal(1));
DynamicEntity a = (DynamicEntity) uow.executeQuery(findQuery);
assertNotNull(a);
ReportQuery countQuery = dynamicHelper.newReportQuery("SimpleB", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
int simpleCountB = ((Number) session.executeQuery(countQuery)).intValue();
assertEquals(1, simpleCountB);
countQuery = dynamicHelper.newReportQuery("SimpleA", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
int simpleCountA = ((Number) session.executeQuery(countQuery)).intValue();
assertEquals(1, simpleCountA);
uow.deleteObject(a);
// em.remove(a.get("b", List.class).get(0));
uow.commit();
countQuery = dynamicHelper.newReportQuery("SimpleB", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
simpleCountB = ((Number) session.executeQuery(countQuery)).intValue();
assertEquals(0, simpleCountB);
countQuery = dynamicHelper.newReportQuery("SimpleA", new ExpressionBuilder());
countQuery.addCount();
countQuery.setShouldReturnSingleValue(true);
simpleCountA = ((Number) session.executeQuery(countQuery)).intValue();
assertEquals(0, simpleCountA);
}
use of org.eclipse.persistence.dynamic.DynamicType in project eclipselink by eclipse-ee4j.
the class SimpleTypes_OneToMany method createSimpleB.
@Test
public void createSimpleB() {
DynamicType simpleTypeB = dynamicHelper.getType("SimpleB");
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();
assertEquals(1, simpleCount);
}
Aggregations