// Path: datastore/sql/JPA/src/main/java/com/jpa/util/HibernateUtil.java
// @SuppressWarnings({"unchecked", "rawtypes", "unused"})
// public class HibernateUtil {
// 
//     private static final Logger log = Logger.getLogger(HibernateUtil.class);
// 
//     /*
//      * Since we will be using annotated classes, it is best to maintain a list
//      * of such classes so we add them up easily
//      */
//     private static final List<Class<?>> classList = new ArrayList() {{
//         add(com.jpa.model.Human.class);
//     }};
//     private static final SessionFactory sessionFactory = buildSessionFactory();
// 
//     private static SessionFactory buildSessionFactory() {
//         /*
//          * Load up the configuration using the hibernate.cfg.xml
//          */
//         Configuration configuration = new Configuration();
//         configuration.configure("hibernate.cfg.xml");
// 
//         /*
//          * Build the registry using the properties in the configuration
//          */
//         ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
//                 configuration.getProperties()).build();
// 
//         /*
//          * Now load the classes
//          */
//         for (Class<?> pojoClass : classList) {
//             log.info("Adding annotated class : " + pojoClass.getCanonicalName());
//             configuration.addAnnotatedClass(pojoClass);
//         }
// 
//         /*
//          * and finally buils the session factory
//          */
//         return configuration.buildSessionFactory(serviceRegistry);
//     }
// 
//     public static SessionFactory getSessionFactory() {
//         return sessionFactory;
//     }
// 
//     public static void shutdown() {
//         getSessionFactory().close();
//     }
// 
//     /**
//      * The main utility method to be used to retreive the transaction.
//      *
//      * @return {@link Transaction} The transaction of the current session
//      */
//     public static Transaction getTransaction() {
//         Session s = getSessionFactory().getCurrentSession();
//         Transaction tx = s.beginTransaction();
//         tx.setTimeout(10);
//         return tx;
//         //return getSessionFactory().getCurrentSession().beginTransaction();;
//     }
// 
// }


import com.jpa.util.HibernateUtil;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.LockOptions;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Example;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;
package com.jpa.dao;



/**
 * Default implementation. All hail !
 *
 * @param <T>
 * @param <ID>
 * @author msaif
 */
@SuppressWarnings({"unchecked", "unused"})
public abstract class GenericHibernateDAO<T, ID extends Serializable>
        implements GenericDAO<T, ID> {

    private static final Logger log = Logger.getLogger(GenericHibernateDAO.class);
    private final Class<T> persistentClass;
    private Session session;

    public GenericHibernateDAO() {
        this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
    }

    protected Session getSession() {
        try {
            if (session == null) {
                log.info("getting current session [getCurrentSession()]");
// Path: datastore/sql/JPA/src/main/java/com/jpa/util/HibernateUtil.java
// @SuppressWarnings({"unchecked", "rawtypes", "unused"})
// public class HibernateUtil {
// 
//     private static final Logger log = Logger.getLogger(HibernateUtil.class);
// 
//     /*
//      * Since we will be using annotated classes, it is best to maintain a list
//      * of such classes so we add them up easily
//      */
//     private static final List<Class<?>> classList = new ArrayList() {{
//         add(com.jpa.model.Human.class);
//     }};
//     private static final SessionFactory sessionFactory = buildSessionFactory();
// 
//     private static SessionFactory buildSessionFactory() {
//         /*
//          * Load up the configuration using the hibernate.cfg.xml
//          */
//         Configuration configuration = new Configuration();
//         configuration.configure("hibernate.cfg.xml");
// 
//         /*
//          * Build the registry using the properties in the configuration
//          */
//         ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(
//                 configuration.getProperties()).build();
// 
//         /*
//          * Now load the classes
//          */
//         for (Class<?> pojoClass : classList) {
//             log.info("Adding annotated class : " + pojoClass.getCanonicalName());
//             configuration.addAnnotatedClass(pojoClass);
//         }
// 
//         /*
//          * and finally buils the session factory
//          */
//         return configuration.buildSessionFactory(serviceRegistry);
//     }
// 
//     public static SessionFactory getSessionFactory() {
//         return sessionFactory;
//     }
// 
//     public static void shutdown() {
//         getSessionFactory().close();
//     }
// 
//     /**
//      * The main utility method to be used to retreive the transaction.
//      *
//      * @return {@link Transaction} The transaction of the current session
//      */
//     public static Transaction getTransaction() {
//         Session s = getSessionFactory().getCurrentSession();
//         Transaction tx = s.beginTransaction();
//         tx.setTimeout(10);
//         return tx;
//         //return getSessionFactory().getCurrentSession().beginTransaction();;
//     }
// 
// }


// Path: datastore/sql/JPA/src/main/java/com/jpa/dao/GenericHibernateDAO.java
import com.jpa.util.HibernateUtil;
import org.apache.log4j.Logger;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.LockOptions;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Example;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
import java.util.List;

package com.jpa.dao;



/**
 * Default implementation. All hail !
 *
 * @param <T>
 * @param <ID>
 * @author msaif
 */
@SuppressWarnings({"unchecked", "unused"})
public abstract class GenericHibernateDAO<T, ID extends Serializable>
        implements GenericDAO<T, ID> {

    private static final Logger log = Logger.getLogger(GenericHibernateDAO.class);
    private final Class<T> persistentClass;
    private Session session;

    public GenericHibernateDAO() {
        this.persistentClass = (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
    }

    protected Session getSession() {
        try {
            if (session == null) {
                log.info("getting current session [getCurrentSession()]");
                session = HibernateUtil.getSessionFactory().getCurrentSession();