Hibernate documentation code is unclear

0

My question is regarding a code that is in the Hibernate documentation. I just could not understand the notation they used in the criteria.where () part. Just notice how it was put: Person_.name . Can someone explain me? Here's the snippet where this is what I said:

CriteriaBuilder builder = entityManager.getCriteriaBuilder();

CriteriaQuery<Person> criteria = builder.createQuery( Person.class );
Root<Person> root = criteria.from( Person.class );
criteria.select( root );
criteria.where( builder.equal( root.get( Person_.name ), "John Doe" ) );

List<Person> persons = entityManager.createQuery( criteria ).getResultList();

I've tried to do the same, but here it says "Can not be resolved to a variable" in that snippet.

The documentation is recent, following the link: Documentation Hibernate

    
asked by anonymous 28.04.2017 / 02:47

0 answers