package com.hida.dao;

import java.io.Serializable;
import java.lang.reflect.ParameterizedType;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * missing javadocs
 *
 * @author lruffin
 * @param <PK>
 * @param <T>
 */
public abstract class AbstractDao<PK extends Serializable, T> {

    /**
     *      
     */
    private final Class<T> persistentClass;

    /**
     * 
     */
    @SuppressWarnings("unchecked")
    public AbstractDao() {
        this.persistentClass = (Class<T>) ((ParameterizedType) this.getClass().getGenericSuperclass()).getActualTypeArguments()[1];
    }

    /**
     * 
     */
    @Autowired
    private SessionFactory sessionFactory;

    /**
     * 
     * @return 
     */
    protected Session getSession() {
        return sessionFactory.getCurrentSession();
    }

    /**
     * 
     * @param key
     * @return 
     */
    @SuppressWarnings("unchecked")
    public T getByKey(PK key) {
        return (T) getSession().get(persistentClass, key);
    }

    /**
     * 
     * @param entity 
     */
        
    public void persist(T entity) {
        getSession().persist(entity);
    }

    /**
     * 
     * @param entity 
     */
    public void delete(T entity) {
        getSession().delete(entity);
    }

    /**
     * 
     * @return 
     */
    protected Criteria createEntityCriteria() {
        return getSession().createCriteria(persistentClass);
    }

}

@@ -89,17 +89,16 @@
 edType;%0A
-%0A
 import o
@@ -262,23 +262,127 @@
 %0A * 
-missing javadoc
+AbstractDao acts as base implementation for all Dao classes and provides%0A * wrapper methods for all Hibernate operation
 s%0A *
@@ -415,16 +415,51 @@
 ram %3CPK%3E
+ Persistent Key of the calling POJO
 %0A * @par
@@ -464,16 +464,25 @@
 aram %3CT%3E
+ The POJO
 %0A */%0Apub
@@ -558,21 +558,27 @@
 %0A     * 
-     
+The class T
 %0A     */
@@ -630,32 +630,43 @@
 %0A    /**%0A     * 
+Constructor
 %0A     */%0A    @Su
@@ -863,32 +863,8 @@
  %7D%0A%0A
-    /**%0A     * %0A     */%0A
     
@@ -933,32 +933,125 @@
 %0A     * 
-%0A     * @return 
+Returns the current session associated with the current transaction%0A     *%0A     * @return the current session
 %0A     */
@@ -1165,42 +1165,135 @@
   * 
-%0A     * @param key%0A     * @return 
+Retrieves a persisted object using a persistent key%0A     *%0A     * @param key The persistent key%0A     * @return persisted object
 %0A   
@@ -1437,32 +1437,57 @@
 %0A    /**%0A     * 
+Persists an object%0A     *
 %0A     * @param e
@@ -1496,25 +1496,34 @@
 ity 
-%0A     */
+Object to be saved
 %0A     
-   
+*/
 %0A   
@@ -1607,32 +1607,73 @@
 %0A    /**%0A     * 
+Removes an object from persistence%0A     *
 %0A     * @param e
@@ -1678,16 +1678,36 @@
  entity 
+Object to be removed
 %0A     */
@@ -1801,16 +1801,112 @@
 %0A     * 
+Creates and returns a Criteria object that can be used to filter%0A     * persisted objects%0A     *
 %0A     * 
@@ -1913,16 +1913,24 @@
 @return 
+Criteria
 %0A     */

Add javadocs to AbstractDao