use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class ILikeTest method prepareData.
@BeforeEach
public void prepareData(SessionFactoryScope scope) {
scope.inTransaction(em -> {
BasicEntity be1 = new BasicEntity(1, "Product_one");
em.persist(be1);
BasicEntity be2 = new BasicEntity(2, "proDUct two");
em.persist(be2);
BasicEntity be3 = new BasicEntity(3, "Product three");
em.persist(be3);
BasicEntity be4 = new BasicEntity(4, "pROducT four");
em.persist(be4);
BasicEntity be5 = new BasicEntity(5, "Product five");
em.persist(be5);
BasicEntity be6 = new BasicEntity(6, "Prodact six");
em.persist(be6);
BasicEntity be7 = new BasicEntity(7, "prodACt seven");
em.persist(be7);
BasicEntity be8 = new BasicEntity(8, "Prod_act eight");
em.persist(be8);
BasicEntity be9 = new BasicEntity(9, "prod_ACt nine");
em.persist(be9);
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class ILikeCriteriaTest method testNotLikeEscape.
@Test
public void testNotLikeEscape(SessionFactoryScope scope) {
scope.inTransaction(session -> {
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(BasicEntity.class);
Root<BasicEntity> from = cq.from(BasicEntity.class);
cq.where(cb.notLike(from.get("data"), cb.literal("Pr%$_%"), cb.literal('$')));
Query q = session.createQuery(cq);
List l = q.getResultList();
assertEquals(7, l.size());
cq.where(cb.notLike(from.get("data"), cb.literal("Pr%$_%"), '$'));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(7, l.size());
cq.where(cb.notLike(from.get("data"), "Pr%$_%", cb.literal('$')));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(7, l.size());
cq.where(cb.notLike(from.get("data"), "Pr%$_%", '$'));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(7, l.size());
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class ILikeCriteriaTest method testIlike.
@Test
public void testIlike(SessionFactoryScope scope) {
scope.inTransaction(session -> {
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(BasicEntity.class);
Root<BasicEntity> from = cq.from(BasicEntity.class);
cq.where(cb.ilike(from.get("data"), "Produ%"));
Query q = session.createQuery(cq);
List l = q.getResultList();
assertEquals(5, l.size());
cq.where(cb.ilike(from.get("data"), cb.literal("Produ%")));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(5, l.size());
});
}
use of org.hibernate.testing.orm.domain.gambit.BasicEntity in project hibernate-orm by hibernate.
the class ILikeCriteriaTest method testNotIlikeEscape.
@Test
public void testNotIlikeEscape(SessionFactoryScope scope) {
scope.inTransaction(session -> {
HibernateCriteriaBuilder cb = session.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery(BasicEntity.class);
Root<BasicEntity> from = cq.from(BasicEntity.class);
cq.where(cb.notIlike(from.get("data"), cb.literal("Pr%$_%"), cb.literal('$')));
Query q = session.createQuery(cq);
List l = q.getResultList();
assertEquals(6, l.size());
cq.where(cb.notIlike(from.get("data"), cb.literal("Pr%$_%"), '$'));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(6, l.size());
cq.where(cb.notIlike(from.get("data"), "Pr%$_%", cb.literal('$')));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(6, l.size());
cq.where(cb.notIlike(from.get("data"), "Pr%$_%", '$'));
q = session.createQuery(cq);
l = q.getResultList();
assertEquals(6, l.size());
});
}
Aggregations