<commit_before>/**
 * <p>Title: HibernateDAO Class>
 * <p>Description:	HibernateDAO is default implemention of AbstractDAO through Hibernate ORM tool.
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 * Created on Mar 16, 2005
 */

package edu.wustl.catissuecore.dao;

import java.util.List;
import java.util.Vector;

import sun.security.action.GetLongAction;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import edu.wustl.catissuecore.domain.Participant;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.common.util.dbManager.DBUtil;
import edu.wustl.common.util.logger.Logger;

/**
 * Default implemention of AbstractDAO through Hibernate ORM tool.
 * @author kapil_kaveeshwar
 */
public class HibernateDAO extends AbstractDAO
{

    protected Session session = null;

    protected Transaction tx = null;
    
    public void openSession() throws DAOException
    {
        try
        {
            session = DBUtil.currentSession();
            tx = session.beginTransaction();
        }
        catch (HibernateException dbex)
        {
            Logger.out.error(dbex.getMessage(),dbex);
            throw handleException(dbex, "Object can not be added.", tx);
        }
        catch (Exception dbex)
        {
            Logger.out.error(dbex.getMessage(),dbex);
            throw handleException(dbex, "Object can not be added.", tx);
        }
    }

    public void closeSession() throws DAOException
    {
        try
        {
            tx.commit();
        }
        catch (HibernateException dbex)
        {
            throw handleException(dbex, "Object can not be added.", tx);
        }
        finally
        {
            DBUtil.closeSession();
        }
    }

    /**
     * Saves the persistent object in the database.
     * @param session The session in which the object is saved.
     * @param obj The object to be saved.
     * @throws HibernateException Exception thrown during hibernate operations.
     * @throws DAOException
     */
    public void insert(Object obj) throws DAOException
    {
        try
        {
            session.save(obj);
        }
        catch(HibernateException hibExp)
        {
            Logger.out.error(hibExp.getMessage(),hibExp);<commit_msg>*** empty log message ***<commit_after>/**
 * <p>Title: HibernateDAO Class>
 * <p>Description:	HibernateDAO is default implemention of AbstractDAO through Hibernate ORM tool.
 * Copyright:    Copyright (c) year
 * Company: Washington University, School of Medicine, St. Louis.
 * @author <NAME>
 * @version 1.00
 * Created on Mar 16, 2005
 */

package edu.wustl.catissuecore.dao;

import java.util.List;
import java.util.Vector;

import sun.security.action.GetLongAction;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;
import edu.wustl.catissuecore.domain.Participant;
import edu.wustl.catissuecore.util.global.Constants;
import edu.wustl.common.beans.NameValueBean;
import edu.wustl.common.util.dbManager.DAOException;
import edu.wustl.common.util.dbManager.DBUtil;
import edu.wustl.common.util.logger.Logger;

/**
 * Default implemention of AbstractDAO through Hibernate ORM tool.
 * @author kapil_kaveeshwar
 */
public class HibernateDAO extends AbstractDAO
{

    protected Session session = null;

    protected Transaction tx = null;
    
    public void openSession() throws DAOException
    {
        try
        {
            session = DBUtil.currentSession();
            tx = session.beginTransaction();
        }
        catch (HibernateException dbex)
        {
            Logger.out.error(dbex.getMessage(),dbex);
            throw handleException(dbex, "Object can not be added.", tx);
        }
        catch (Exception dbex)
        {
            Logger.out.error(dbex.getMessage(),dbex);
            throw handleException(dbex, "Object can not be added.", tx);
        }
    }

    public void closeSession() throws DAOException
    {
        try
        {
            tx.commit();
        }
        catch (HibernateException dbex)
        {
            throw handleException(dbex, "Object can not be added.", tx);
        }
        finally
        {
            DBUtil.closeSession();
        }
    }

    /**
     * Saves the persistent object in the database.
     * @param session The session in which the object is saved.
     * @param obj The object to be saved.
     * @throws HibernateException Exception thrown during hibernate operations.
     * @throws DAOException
     */
    public void insert(Object obj) throws DAOException
    {
        try
        {
            session.save(obj);
        }
        catch(HibernateException hibExp)
        {
            Logger.out.error(hibExp.getMessage(),hibExp);
            throw new DAOException(hibExp);
{'fraction_non_alphanumeric': 0.09584476675813407, 'fraction_numerical': 0.0035280282242257936, 'mean_word_length': 2.457317073170732, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7055991', 'n_tokens_mistral': 1522, 'n_tokens_neox': 1465, 'n_words': 376}