package jp.co.y_net.amm.dao;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Component;


@Component("freeDao")
public class FreeDao extends AbstractDao {

    public void copy(final String sql) {
        HibernateTemplate hibernateTemplate = getHibernateTemplate();
        hibernateTemplate.execute(new HibernateCallback<Object>() {
            public Object doInHibernate(Session session) throws HibernateException {
                Query query = session.createSQLQuery(sql);
                Object result = query.list();
                return result;
            }
        });
        hibernateTemplate.clear();
    }
}
