Figure 896. Criteria entity metamodel Slide presentation Create comment in forum

Figure 897. Criteria query Slide presentation Create comment in forum
final CriteriaQuery<StudyCourse> criteria = builder.
   createQuery( StudyCourse.class );
final Root<StudyCourse> studyCourseRoot =
   criteria.from(StudyCourse.class);
criteria.select( studyCourseRoot );
criteria.where( builder.like( studyCourseRoot.
  get(StudyCourse_.shortName), "C%" ) );
final List<StudyCourse> studyCourses = entityManager.
  createQuery( criteria ).getResultList();

studyCourses.stream().map(s -> "Read '" + s + "'").
  forEach(System.out::println);

What about SQL injection?


Figure 898. No injection susceptibility Slide presentation Create comment in forum
select studycours0_.shortName as shortNam1_0_,
       studycours0_.fullName  as fullName2_0_
from StudyCourse studycours0_
where studycours0_.shortName like ?