/**
 * hibernatedemo:com.learning.hibernate.main Created on Dec 27, 2015
 *
 * 
 */
package com.learning.hibernate.main;

import org.hibernate.Session;

import com.learning.hibernate.dto.UserDetails;
import com.learning.hibernate.util.SessionFactoryCreatorDemo;

/**
 * @author mandheer
 *         
 */
public class HibernateCRUDTest {
	
	/**
	 * @param args
	 *            
	 *            main HibernateTest void
	 */
	public static void main(String[] args) {
		UserDetails userDetails = null;
		Session session = SessionFactoryCreatorDemo.getSessionFactory().openSession();
		try {
			/*
			 * session.beginTransaction(); for (int i = 50; i <= 100; i++) { userDetails = new
			 * UserDetails(); userDetails.setUserName("User Name " + i); session.save(userDetails);
			 * } session.getTransaction().commit(); session.close();
			 */
			session = SessionFactoryCreatorDemo.getSessionFactory().openSession();
			session.beginTransaction();
			userDetails = session.get(UserDetails.class, 51l);
			userDetails.setUserName("Updated User");
			// session.delete(userDetails);
			// session.update(userDetails);
			session.getTransaction().commit();
			session.close();
			System.out.println(userDetails);
		} finally {
			if (session.isOpen())
				session.close();
			SessionFactoryCreatorDemo.shutdown();
		}
	}
	
}

@@ -133,29 +133,269 @@
 ort 
-org.hibernate.Session
+java.util.List;%0D%0A%0D%0Aimport org.hibernate.Criteria;%0D%0Aimport org.hibernate.Session;%0D%0Aimport org.hibernate.criterion.Criterion;%0D%0Aimport org.hibernate.criterion.ProjectionList;%0D%0Aimport org.hibernate.criterion.Projections;%0D%0Aimport org.hibernate.criterion.Restrictions
 ;%0D%0A%0D
@@ -1205,24 +1205,27 @@
 tion();%0D%0A%09%09%09
+// 
 userDetails 
@@ -1267,16 +1267,19 @@
 l);%0D%0A%09%09%09
+// 
 userDeta
@@ -1383,24 +1383,27 @@
 tails);%0D%0A%09%09%09
+// 
 session.getT
@@ -1421,32 +1421,35 @@
 ).commit();%0D%0A%09%09%09
+// 
 session.close();
@@ -1457,38 +1457,555 @@
 %0A%09%09%09
-System.out.println(userDetails
+Criteria criteria = session.createCriteria(UserDetails.class);%0D%0A%09%09%09ProjectionList p1 = Projections.projectionList();%0D%0A%09%09%09p1.add(Projections.property(%22userName%22));%0D%0A%09%09%09// criteria.add(Restrictions.gt(%22userId%22, 49l)).add(Restrictions.like(%22userName%22,%0D%0A%09%09%09// %22Up%25%22));%0D%0A%09%09%09Criterion criterion = Restrictions.lt(%22userId%22, 25l);%0D%0A%09%09%09Criterion criterion2 = Restrictions.gt(%22userId%22, 50l);%0D%0A%09%09%09criteria.add(Restrictions.or(criterion, criterion2));%0D%0A%09%09%09// criteria.setProjection(p1);%0D%0A%09%09%09List list = criteria.list();%0D%0A%09%09%09%0D%0A%09%09%09System.out.println(list.size()
 );%0D%0A

modify the hibernate crud.