use of com.haulmont.cuba.core.global.queryconditions.LogicalCondition in project cuba by cuba-platform.
the class QueryConditionsUsageTest method test.
@Test
public void test() {
LogicalCondition condition = and().add(where("u.login like :login")).add(where("u.userRoles ur", "ur.role.name = :roleName")).add(or().add(where("u.foo = :foo")).add(where("u.bar = :bar")));
LoadContext.Query query = LoadContext.createQuery("select u from sec$User u").setCondition(condition).setParameter("login", "admin");
LoadContext<User> loadContext = LoadContext.create(User.class).setQuery(query);
List<User> users = dataManager.loadList(loadContext);
assertEquals(1, users.size());
Optional<User> userOpt = dataManager.load(User.class).query("select u from sec$User u").condition(condition).parameter("login", "admin").optional();
assertTrue(userOpt.isPresent());
}
Aggregations