Example usage for org.hibernate Query setParameterList

List of usage examples for org.hibernate Query setParameterList

Introduction

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

Prototype

Query<R> setParameterList(int position, Object[] values);

Source Link

Usage

From source file:com.square.core.dao.implementations.AgenceDaoImplementation.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override//from   w  w w . java2s  .c om
public List<Agence> rechercheAgencesParIds(List<Long> listeIds) {
    final String requete = "select a from Agence a where a.id in (:listeIds)";
    final Query query = createQuery(requete);
    query.setParameterList("listeIds", listeIds);
    return query.list();
}

From source file:com.square.core.dao.implementations.RelationDaoImplementation.java

License:Open Source License

@Override
public int desactiverRelations(List<Long> idsRelationsADesactiver) {
    final StringBuffer requete = new StringBuffer(
            "update Relation set topActif = false where id in (:idsRelationsADesactiver)");
    final Query query = createQuery(requete.toString());
    query.setParameterList("idsRelationsADesactiver", idsRelationsADesactiver);
    return query.executeUpdate();
}

From source file:com.square.logs.core.dao.implementations.LogDaoImplementation.java

License:Open Source License

@Override
public int supprimerLogsByIds(List<Long> idsASupprimer) {
    // suppression des arguments
    String requete = "DELETE FROM data_argument where log_id in (:idsASupprimer)";
    Query query = createSqlQuery(requete);
    query.setParameterList("idsASupprimer", idsASupprimer);
    query.executeUpdate();//w w  w .j a  v a  2s . c o  m
    // suppression des logs
    requete = "DELETE FROM data_log where id in (:idsASupprimer)";
    query = createSqlQuery(requete);
    query.setParameterList("idsASupprimer", idsASupprimer);
    return query.executeUpdate();
}

From source file:com.swz.mysql.gps.dao.impl.UsermainRepositoryImpl.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Map> queryVehicleList(int userid) {
    Session session = getSessionFactory().getCurrentSession();
    List<Map> list = null;
    Query sql = null;
    List<Integer> groupid = getVehicleGroups(userid);
    // /*from  ww w  . ja va  2  s  .  co m*/
    if (groupid != null && groupid.size() > 0) {
        // ?
        sql = session.createQuery(
                "select new map(vehicle.id,vehicle.car_license_num) from Vehicle vehicle,Usermain_veh usermain_veh where "
                        + "vehicle.vehTeam_ID not in(:groupid) and vehicle.isdelete =0 and vehicle.id =usermain_veh.VehicleID and usermain_veh.UserID =:userid ");
        sql.setParameterList("groupid", groupid);

    }
    // (??)
    else {
        sql = session.createQuery(
                "select new map(vehicle.id,vehicle.car_license_num) from Vehicle vehicle,Usermain_veh usermain_veh where "
                        + " vehicle.isdelete =0 and vehicle.id =usermain_veh.VehicleID and usermain_veh.UserID =:userid ");
    }
    sql.setInteger("userid", userid);
    list = sql.list();
    // if (list != null) {
    // System.out.println("?" + list.size());
    // }
    return list;
}

From source file:com.swz.mysql.gps.dao.impl.VehcleRepositoryImpl.java

@SuppressWarnings("unchecked")
@Override// w ww . j a va  2s  .c o  m
public List<String> findVehclesName(List<Integer> vehicleids) {

    List<String> vehcleNum;
    Query sql = getSessionFactory().getCurrentSession()
            .createQuery("select car_license_num from Vehicle car where car.id in :vehicleid ");
    sql.setParameterList("vehicleid", vehicleids);
    try {
        vehcleNum = sql.list();
    } catch (Exception e) {
        logger.error("????\n\t" + " Vehicleid  ?");
        throw new RuntimeException();
    }
    return vehcleNum;
}

From source file:com.swz.mysql.gps.dao.impl.VehcleRepositoryImpl.java

@SuppressWarnings("unchecked")
public List<Vehicle> findVehcles(List<Integer> vehicleids) {
    List<Vehicle> vehicles = null;
    Query sql = getSessionFactory().getCurrentSession()
            .createQuery("from Vehicle car where car.id in :vehicleid ");
    sql.setParameterList("vehicleid", vehicleids);
    try {//w  ww .  j ava  2  s .  c om
        vehicles = sql.list();
    } catch (Exception e) {
        logger.error("???\n\t" + " vehicleids  ?");
        throw new RuntimeException();
    }
    return vehicles;
}

From source file:com.ten45.entity.aggregation.CrawlElementDaoBase.java

/**
 * @see com.ten45.entity.aggregation.CrawlElementDao#load(int, java.lang.Long[])
 *//*from   w ww.j a  v a  2s  . c om*/
public java.util.List load(final int transform, final java.lang.Long[] id) {
    if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
        throw new IllegalArgumentException("CrawlElement.load - 'id' can not be null");
    }
    org.hibernate.Query query = getSession().createQuery(
            "from com.ten45.entity.aggregation.CrawlElement as entity where entity.id in ( :idList )");
    query.setParameterList("idList", id);
    final java.util.List<com.ten45.entity.aggregation.CrawlElement> list = query.list();
    transformEntities(transform, list);
    return list;
}

From source file:com.ten45.entity.aggregation.CrawlElementDaoBase.java

/**
 * @see com.ten45.entity.aggregation.CrawlElementDao#load(int, java.lang.Long[])
 *//* w  ww. ja v  a  2  s.  c  om*/
public java.util.List load(final int transform, final java.util.Collection<java.lang.Long> id) {
    if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
        throw new IllegalArgumentException("CrawlElement.load - 'id' can not be null");
    }
    org.hibernate.Query query = getSession().createQuery(
            "from com.ten45.entity.aggregation.CrawlElement as entity where entity.id in ( :idList )");
    query.setParameterList("idList", id);
    final java.util.List<com.ten45.entity.aggregation.CrawlElement> list = query.list();
    transformEntities(transform, list);
    return list;
}

From source file:com.ten45.entity.aggregation.CrawlSessionDaoBase.java

/**
 * @see com.ten45.entity.aggregation.CrawlSessionDao#load(int, java.lang.Long[])
 *//*ww  w  . j av a  2  s .co  m*/
public java.util.List load(final int transform, final java.lang.Long[] id) {
    if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
        throw new IllegalArgumentException("CrawlSession.load - 'id' can not be null");
    }
    org.hibernate.Query query = getSession().createQuery(
            "from com.ten45.entity.aggregation.CrawlSession as entity where entity.id in ( :idList )");
    query.setParameterList("idList", id);
    final java.util.List<com.ten45.entity.aggregation.CrawlSession> list = query.list();
    transformEntities(transform, list);
    return list;
}

From source file:com.ten45.entity.aggregation.CrawlSessionDaoBase.java

/**
 * @see com.ten45.entity.aggregation.CrawlSessionDao#load(int, java.lang.Long[])
 *//* w w w .  j  a va2  s .  com*/
public java.util.List load(final int transform, final java.util.Collection<java.lang.Long> id) {
    if (com.ten45.basic.util.CollectionUtil.isEmpty(id)) {
        throw new IllegalArgumentException("CrawlSession.load - 'id' can not be null");
    }
    org.hibernate.Query query = getSession().createQuery(
            "from com.ten45.entity.aggregation.CrawlSession as entity where entity.id in ( :idList )");
    query.setParameterList("idList", id);
    final java.util.List<com.ten45.entity.aggregation.CrawlSession> list = query.list();
    transformEntities(transform, list);
    return list;
}