How does Example criterion work in Hibernate?

In Hibernate, we can create an object with desired properties. Then we can use this object to search for objects with similar object. For this we can use org.hibernate.criterion.Example criterion.

Egg. First we create a sample book object of author Richard and category mystery. Then we search for similar books.

Book book = new Book();
List results = session.createCriteria(Book.class)
.add( Example.create(book) )

Leave a Reply

Your email address will not be published. Required fields are marked *