
How to use Equal and Not Equal criteria query in hibernate?

<class name="com.bean.Organization" table="ORGANIZATION"> <id name="orgId" column="ORG_ID" type="long"> <generator class="native"/> </id> <property name="organizationName" column="ORGANISATION_NAME" type="string" length="500"/> <property name="town" column="TOWN" type="string" length="200"/> </class>
List of organisation where town equals to pune.
List organizationList = session.createCriteria(Organization.class).add(Restrictions.eq("town","pune")).list();
List of organisation where town not equals pune.
List organizationList = session.createCriteria(Organization.class).add(Restrictions.ne("town","pune")).list();
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.