Hibernate criteria returns empty list but data exists. Using annotation Hibernate criteria returns empty list but data exists. Using annotation database database

Hibernate criteria returns empty list but data exists. Using annotation


For those who are still looking for an answer to this question as I was, Please check your hibernate config xml and make sure your hibernate entity is declared there.


I just had almost identical problem and my issue was that in applicationContext.xml I had a wrong package name specified for scanning for sessionFactory. Interestingly, Eclipse did not show me any exceptions, errors, so to debug it was extremely hard:

<bean id="sessionFactory"    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">    <property name="dataSource" ref="dataSource" />    <property name="packagesToScan" value="{{Wrong Package Name}}" /></bean>


First of all, I guess you don't need private EmpPrmryKey compositeId; in Employee class.

I created local project with the same entities and the same query you provided worked (it returned expected result). So, If result still empty then you may check if you are looking correct table or database.