use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class DataDomainIT method testEntityResolverRefresh.
@Test
public void testEntityResolverRefresh() throws Exception {
DataDomain domain = new DataDomain("dom1");
org.apache.cayenne.map.EntityResolver resolver = domain.getEntityResolver();
assertNotNull(resolver);
DataMap map = new DataMap("map");
ObjEntity entity = new ObjEntity("TestEntity");
map.addObjEntity(entity);
domain.addDataMap(map);
assertSame(entity, resolver.getObjEntity("TestEntity"));
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class DeleteRulesIT method restoreReverse.
private void restoreReverse(ObjRelationship reverse) {
ObjEntity entity = context.getEntityResolver().getObjEntity(DeleteRuleFlatA.class);
ObjRelationship relationship = entity.getRelationship(DeleteRuleFlatA.FLAT_B.getName());
relationship.getTargetEntity().addRelationship(reverse);
context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatA");
context.getEntityResolver().getClassDescriptorMap().removeDescriptor("DeleteRuleFlatB");
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class DeleteRulesIT method changeDeleteRule.
private int changeDeleteRule(int deleteRule) {
ObjEntity entity = context.getEntityResolver().getObjEntity(DeleteRuleFlatA.class);
ObjRelationship relationship = entity.getRelationship(DeleteRuleFlatA.FLAT_B.getName());
int oldRule = relationship.getDeleteRule();
relationship.setDeleteRule(deleteRule);
return oldRule;
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class FluentSelectPrefetchRouterActionQualifiedEntityIT method testPrefetchEmployee.
@Test
public void testPrefetchEmployee() {
ObjEntity departmentEntity = resolver.getObjEntity(Department.class);
ObjectSelect<Employee> query = ObjectSelect.query(Employee.class, Employee.NAME.eq("abc")).prefetch(Employee.TO_DEPARTMENT.disjoint());
FluentSelectPrefetchRouterAction action = new FluentSelectPrefetchRouterAction();
MockQueryRouter router = new MockQueryRouter();
action.route(query, router, resolver);
assertEquals(1, router.getQueryCount());
PrefetchSelectQuery prefetch = (PrefetchSelectQuery) router.getQueries().get(0);
assertEquals(departmentEntity.getName(), prefetch.getEntityName());
assertEquals(ExpressionFactory.exp("db:employees.NAME = 'abc' and (db:employees.PERSON_TYPE = 'EE' " + "or db:employees.PERSON_TYPE = 'EM')"), prefetch.getWhere());
}
use of org.apache.cayenne.map.ObjEntity in project cayenne by apache.
the class FluentSelectPrefetchRouterActionIT method testPaintings1.
@Test
public void testPaintings1() {
ObjEntity paintingEntity = resolver.getObjEntity(Painting.class);
ObjectSelect<Artist> query = ObjectSelect.query(Artist.class, Artist.ARTIST_NAME.eq("abc")).prefetch(Artist.PAINTING_ARRAY.disjoint());
FluentSelectPrefetchRouterAction action = new FluentSelectPrefetchRouterAction();
MockQueryRouter router = new MockQueryRouter();
action.route(query, router, resolver);
assertEquals(1, router.getQueryCount());
PrefetchSelectQuery prefetch = (PrefetchSelectQuery) router.getQueries().get(0);
assertEquals(paintingEntity.getName(), prefetch.entityName);
assertEquals(ExpressionFactory.exp("db:toArtist.ARTIST_NAME = 'abc'"), prefetch.getWhere());
}
Aggregations