/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

import hibernate.Userstatistic;
import hibernate.util.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Ani
 */
public class RefreshUserstatistic {
    public static Userstatistic refreshUserstatistic(Userstatistic userstatistic){
        Session session = null;
        try{
            session = HibernateUtil.getSessionFactory().openSession();
            session.beginTransaction();

            Query query = session.createQuery("FROM Userstatistic us WHERE us.username=:username");
            query.setString("username", userstatistic.getUsername());

            return (Userstatistic) query.uniqueResult();
        }finally{
            if (session!=null)
                session.close();
        }
    }

}
