/*
 * Created on Sep 1, 2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package gov.va.med.esr.common.persistent.comms.hibernate;

import java.util.List;

import gov.va.med.esr.common.model.comms.CommsTransLog;
import gov.va.med.esr.common.persistent.comms.CommsTransLogDAO;
import gov.va.med.fw.persistent.DAOException;
import gov.va.med.fw.persistent.hibernate.AbstractDAOImpl;

/**
 * @author DNS   TSAIG
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
public class CommsTransLogDAOImpl extends AbstractDAOImpl implements CommsTransLogDAO{
    
	private static final long serialVersionUID = -6919751063975875307L;

    public void save(CommsTransLog log)  throws DAOException
	{
	    super.getHibernateTemplate().saveOrUpdate(log);
	    
	}
    
    public String findFileNameByMaxId(String fileNameBeforeVersion)  {
        String fileName = null;
     
        org.springframework.orm.hibernate3.HibernateTemplate hibtemplate = super.getHibernateTemplate();
        List fileNames = hibtemplate.findByNamedQueryAndNamedParam("commsTransLogQuery_getFileNameByMaxId", "filePrefix", fileNameBeforeVersion + "%");
        

        
        if (fileNames.size() > 0) {
            fileName = (String)fileNames.get(0);
        }

        
        
        return fileName;
    }
	
}
