Example usage for org.hibernate Query setInteger

List of usage examples for org.hibernate Query setInteger

Introduction

In this page you can find the example usage for org.hibernate Query setInteger.

Prototype

@Deprecated
@SuppressWarnings("unchecked")
default Query<R> setInteger(String name, int val) 

Source Link

Document

Bind a named int-valued parameter.

Usage

From source file:com.liusoft.dlog4j.dao.UserDAO.java

License:Open Source License

/**
 * keep_days,/*from ww w .j  ava2s .c  om*/
 * @param userid
 * @param lastLogin 
 * @param manual_logout 
 * @return
 */
public static int userLogout(int userid, Timestamp lastLogin, boolean manual_logout) {
    Session ssn = getSession();
    if (ssn == null)
        return -1;
    try {
        beginTransaction();
        Query q = ssn.getNamedQuery(manual_logout ? "USER_LOGOUT_1" : "USER_LOGOUT_2");
        q.setInteger("online_status", UserBean.STATUS_OFFLINE);
        if (manual_logout)
            q.setInteger("keep_day", 0);
        q.setInteger("user_id", userid);
        q.setTimestamp("last_time", lastLogin);
        int er = q.executeUpdate();
        commit();
        return er;
    } catch (HibernateException e) {
        rollback();
        throw e;
    }
}

From source file:com.liusoft.dlog4j.dao.VisitStatDAO.java

License:Open Source License

/**
 * /*from  ww w.j  a v a 2  s  .c  om*/
 * TODO: ,
 * @param ssb
 * @throws Exception 
 */
public static void writeStatData(int siteid, int uvCount, int source) throws Exception {
    Calendar cal = Calendar.getInstance();
    int statDate = getStatDate(cal);
    Session ssn = getSession();
    try {
        beginTransaction();
        Query update_q = ssn.getNamedQuery((siteid > 0) ? "UPDATE_SITE_STAT_1" : "UPDATE_SITE_STAT_2");
        update_q.setInteger(0, uvCount);
        update_q.setInteger(1, statDate);
        update_q.setInteger(2, source);
        if (siteid > 0)
            update_q.setInteger(3, siteid);
        if (update_q.executeUpdate() < 1) {
            SiteStatBean ssb = new SiteStatBean();
            ssb.setSiteId(siteid);
            ssb.setUvCount(uvCount);
            ssb.setUpdateTime(new Date());
            ssb.setSource(source);
            ssb.setStatDate(statDate);
            ssn.save(ssb);
        }
        commit();
    } catch (Exception e) {
        rollback();
        throw e;
    }
}

From source file:com.luis.servicios.ManagerEmpleados.java

public Collection<Empleado> findEmpleadoByPuesto(int idPuesto) {

    Session ses = getHibernateTemplate().getSessionFactory().getCurrentSession();

    Query q = ses.createQuery("from Empleado where idPuesto= :puesto");

    q.setInteger("puesto", idPuesto);

    List<Empleado> l = q.list();

    return l;/* ww w  .ja  v a  2  s.  c  o  m*/

}

From source file:com.lushell.tc.dbpaas.api.instance.dao.TaskDAOImpl.java

@Override
public TaskDO getTask(int taskId) {
    Query query = getSession().createQuery("from TaskDO where task_id=:task_id");
    query.setInteger("task_id", taskId);
    return (TaskDO) query.uniqueResult();
}

From source file:com.lushell.tc.dbpaas.api.instance.dao.TaskDAOImpl.java

@Override
public boolean setTaskReady(int taskId, int ready) {
    Query query = getSession().createQuery("update TaskDO set task_ready=:ready " + "where task_id=:id");
    query.setInteger("id", taskId);
    query.setInteger("ready", ready);
    return query.executeUpdate() == 1;
}

From source file:com.matrimony.database.FriendDAO.java

public static List<User> ListFriend(String nameFormId) {
    List<User> listUser = new ArrayList<>();
    Session session = HibernateUtil.getCurrentSession();
    session.beginTransaction();//  ww w.j ava  2  s  .c  om
    Query query = session.createQuery("FROM friend WHERE status=?");
    query.setInteger(0, 2);
    List<Friend> list = query.list();
    session.getTransaction().commit();
    for (int i = 0; i < list.size(); i++) {
        if (nameFormId.equals(list.get(i).getUserInvite())) {
            User u = list.get(0).getUserBeInvite();
            listUser.add(u);
        }
        if (nameFormId.equals(list.get(i).getUserBeInvite())) {
            User u = list.get(0).getUserInvite();
            listUser.add(u);
        }
    }
    return listUser;
}

From source file:com.matrimony.database.FriendDAO.java

public static List<User> ListRequest(String nameFormId) {
    List<User> listUser = new ArrayList<>();
    Session session = HibernateUtil.getCurrentSession();
    session.beginTransaction();/*from  w  w  w .  ja  v a 2s .c  om*/
    Query query = session.createQuery("FROM Friend friend WHERE status=? and userInvite=?");
    query.setString(0, nameFormId);
    query.setInteger(1, 1);
    List<Friend> list = query.list();
    session.getTransaction().commit();
    Collections.sort(list, new Friend.RequestComparator());
    for (int i = 0; i < list.size(); i++) {
        User u = list.get(0).getUserBeInvite();
        listUser.add(u);
    }
    return listUser;
}

From source file:com.matrimony.database.FriendDAO.java

public static List<User> ListInvite(String nameToId) {
    List<User> listUser = new ArrayList<>();
    Session session = HibernateUtil.getCurrentSession();
    session.beginTransaction();//from w w  w. jav  a 2  s.c  om
    Query query = session.createQuery("FROM Friend friend WHERE status=? and userBeInvite=?");
    query.setString(0, nameToId);
    query.setInteger(1, 1);
    List<Friend> list = query.list();
    session.getTransaction().commit();
    for (int i = 0; i < list.size(); i++) {
        User u = list.get(0).getUserInvite();
        listUser.add(u);
    }
    return listUser;
}

From source file:com.mitzi.mc.DAOProductoImpl.java

public Producto buscarPorId(int id) {
    begin();//from  ww w . j a v  a2 s.co m
    Query q = getSession().createQuery("from Producto where id = :id");
    q.setInteger("id", id);
    Producto p = (Producto) q.uniqueResult();
    commit();
    close();
    return p;

}

From source file:com.mycompany.desktopinlamninguppgift2.repository.DeveloperRepository.java

public void updateDeveloper(Developer developer) {

    Session session = NewHibernateUtil.getSession();
    session.beginTransaction();/*from   w ww .  ja va  2 s  .c om*/

    Query q = session.createQuery("update Developer set developerName = :newName where developerId = :id");
    q.setParameter("newName", developer.getDeveloperName());
    q.setInteger("id", developer.getDeveloperId());
    q.executeUpdate();

    session.getTransaction().commit();
    session.close();
}