List of usage examples for javax.persistence Query setParameter
Query setParameter(int position, Object value);
From source file:com.ecarride.App.java
public static void ResetDriverWorkStatus() { Iterator<TlcDriver> iterator = tlcDrivers.iterator(); while (iterator.hasNext()) { TlcDriver temp = iterator.next(); if (!temp.isInTrouble()) continue; EntityTransaction updateTransaction = entityManager.getTransaction(); updateTransaction.begin();/*from w w w. ja v a 2s . c om*/ Query query = entityManager .createQuery("UPDATE Driver d SET d.baseApproved = 0, d.status = 0" + "WHERE d.id= :id"); query.setParameter("id", temp.getDriver().getId()); query.executeUpdate(); updateTransaction.commit(); } }
From source file:nc.noumea.mairie.appock.core.utility.AppockUtil.java
public static void setParameter(Query query, String parameter, Object value) { query.setParameter(parameter, value); }
From source file:com.ny.apps.dao.BaseDaoImpl.java
/** * ??//from w ww .ja va 2s . c o m * @param query * @param params ? * @return */ public static Query prepareParameterizedQuery(Query query, Object... params) { if (params == null) { return query; } int i = 0; for (Object param : params) { if (param == null) { continue; } query.setParameter(++i, param); } return query; }
From source file:org.apache.cxf.fediz.service.idp.service.jpa.IdpDAOJPAImpl.java
static IdpEntity getIdpEntity(String realm, EntityManager em) { Query query = null; query = em.createQuery("select i from IDP i where i.realm=:realm"); query.setParameter("realm", realm); //@SuppressWarnings("rawtypes") return (IdpEntity) query.getSingleResult(); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static UserDatabase getUserWithID(long id) { MiscUtil.assertNotNull(id, "UserID"); Logger.trace("Getting Userinformation with ID " + id + " from database."); List<UserDatabase> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserID")); query.setParameter("id", id); result = query.getResultList();// ww w.j a v a 2 s. co m Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (UserDatabase) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static UserDatabase getUsersWithOADBID(long id) { MiscUtil.assertNotNull(id, "OADBID"); Logger.trace("Getting Userinformation with OADBID " + id + " from database."); List<UserDatabase> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getUsersWithOADBID")); query.setParameter("id", id); result = query.getResultList();/*from w w w.j ava2 s . co m*/ Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (UserDatabase) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static UserDatabase getUserWithUserBPKWBPK(String bpkwbpk) { MiscUtil.assertNotNull(bpkwbpk, "bpk/wbpk"); Logger.trace("Getting Userinformation with ID " + bpkwbpk + " from database."); List<UserDatabase> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserBPKWBPK")); query.setParameter("bpk", bpkwbpk); result = query.getResultList();//from w w w . ja va 2 s. c om Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (UserDatabase) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static UserDatabase getUserWithUserName(String username) { MiscUtil.assertNotNull(username, "UserName"); Logger.trace("Getting Userinformation with ID " + username + " from database."); List<UserDatabase> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getUserWithUserUsername")); query.setParameter("username", username); result = query.getResultList();/*from w w w . j a v a 2 s. c o m*/ Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (UserDatabase) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static UserDatabase getNewUserWithTokken(String tokken) { MiscUtil.assertNotNull(tokken, "bpk/wbpk"); Logger.trace("Getting Userinformation with Tokken " + tokken + " from database."); List<UserDatabase> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getNewUserWithUserTokken")); query.setParameter("tokken", tokken); result = query.getResultList();//from w ww .j a v a 2 s.co m Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (UserDatabase) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
@SuppressWarnings("rawtypes") public static List<OnlineApplication> searchOnlineApplications(String id) { MiscUtil.assertNotNull(id, "OnlineApplictionID"); Logger.trace("Getting OnlineApplication with ID " + id + " from database."); List<OnlineApplication> result; EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("searchOnlineApplicationsWithID")); query.setParameter("id", "%" + id + "%"); result = query.getResultList();// w ww . j a va2 s. co m Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result; }