findByCriteria in hibernate Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of findByCriteria in hibernate without wasting too much if your time.

The question is published on by Tutorial Guruji team.

In my generic Hibernate DAO which consists of a method findByCriteria

protected List<T> findByCriteria(Criterion... criterion) {
        Criteria crit = getSession().createCriteria(getPersistentClass());
        for (Criterion c : criterion) {
        return crit.list();

Now myDao extends generic dao.Now how can i use findByCriterion to get objects satisfying certain conditions.Can any one give some examples?


I do not know what dao.Now is but, you can use this method like this:

List<YourObject> result = findByCriteria("name", "Fritz%"));

Assuming that YourObject has a property name that should begin with Fritz

See documentation

We are here to answer your question about findByCriteria in hibernate - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji