Search code examples
javahibernatehibernate-criteria

Hibernate Criteria query with ge operator is getting stuck forever


I am having an issue with hibernate criteria with "ge" operator in my query. My Criteria code is below.Can someone please help on guiding that what is the root cause of this abnormal behavior of criteria.Also to mention my table just has 5 records.

 LevelPriority levelPriorirty = (LevelPriority) crit.uniqueResult();
    List<LevelPriority> resList = new ArrayList<>();
    Criteria newcrit = getSess().createCriteria(LevelPriority.class);
    if (levelPriorirty != null) {

        newcrit.add(Restrictions.ge("levelPriority",     levelPriorirty.getLevelPriority()));
        resList = (List<LevelPriority>) newcrit.list();

Solution

  • Finally i was able to solve it. I found that i was opening the new session each time the criteria was being created. So i changed below with the later one.

      sessionFactory.openSession();
    

    changed to

      sessionFactory.getCurrentSession();