use of com.haulmont.cuba.testmodel.entity_cache.ParentCachedEntity in project cuba by cuba-platform.
the class EntityCacheTestClass method testAdditionalParametersUsedDuringLazyLoading.
@Test
public void testAdditionalParametersUsedDuringLazyLoading() {
try {
provider.setParam("ONE");
ParentCachedEntity parent;
try (Transaction tx = cont.persistence().createTransaction()) {
Query query = cont.entityManager().createQuery("select p from test$ParentCachedEntity p where p.id = :id");
query.setParameter("id", cachedParent.getId());
parent = (ParentCachedEntity) query.getResultList().get(0);
javax.persistence.EntityManager em = cont.entityManager().getDelegate();
assertNotNull(parent);
List<ChildCachedEntity> children = parent.getChildren();
assertNotNull(children);
/* Next line checks that changes from eclipselink 2.7.3-19-cuba works:
* DatabaseValueHolder passes additional criteria parameters using CubaUtil.
* Entity in shared cache has no access to ClientSession with additional criteria parameters
* so they has to be passed using another way.
*
* otherwise it will be exception:
* org.eclipse.persistence.exceptions.QueryException:
* Exception Description: No value was provided for the session property [testAdditional]
*/
assertEquals(1, children.size());
tx.commit();
}
} finally {
provider.setParam(null);
}
}
Aggregations