List of usage examples for javax.persistence EntityManager createQuery
public Query createQuery(CriteriaDelete deleteQuery);
Query
for executing a criteria delete query. 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();// w w w. java 2s . 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 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 av a 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 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();/* w w w . j a 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 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 w w . j a va2 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 OnlineApplication getOnlineApplication(long dbid) { MiscUtil.assertNotNull(dbid, "OnlineApplictionID"); Logger.trace("Getting OnlineApplication with DBID " + dbid + " from database."); List result;//from w w w. ja v a 2s . co m EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithDBID")); //query.setParameter("id", id+"%"); query.setParameter("id", dbid); result = query.getResultList(); Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return (OnlineApplication) 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();//from ww w .j a v a 2s. c o m Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } return result; }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static OnlineApplication getActiveOnlineApplication(String id) { MiscUtil.assertNotNull(id, "OnlineApplictionID"); Logger.trace("Getting OnlineApplication with ID " + id + " from database."); List result;//w w w.j av a 2 s . co m EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getActiveOnlineApplicationWithID")); //query.setParameter("id", id+"%"); query.setParameter("id", StringEscapeUtils.escapeHtml4(id)); result = query.getResultList(); Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.debug("No entries found."); return null; } if (result.size() > 1) { Logger.warn("OAIdentifier match to more then one DB-entry!"); return null; } return (OnlineApplication) result.get(0); }
From source file:at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead.java
public static OnlineApplication getOnlineApplication(String id) { MiscUtil.assertNotNull(id, "OnlineApplictionID"); Logger.trace("Getting OnlineApplication with ID " + id + " from database."); List result;//from w ww . j ava2 s . co m EntityManager session = ConfigurationDBUtils.getCurrentSession(); javax.persistence.Query query = session.createQuery(QUERIES.get("getOnlineApplicationWithID")); //query.setParameter("id", id+"%"); query.setParameter("id", id); result = query.getResultList(); Logger.trace("Found entries: " + result.size()); if (result.size() == 0) { Logger.trace("No entries found."); return null; } if (result.size() > 1) { Logger.warn("OAIdentifier match to more then one DB-entry!"); return null; } return (OnlineApplication) result.get(0); }
From source file:com.siberhus.ngai.core.CrudHelper.java
@SuppressWarnings("unchecked") public final static List<Object> getAll(EntityManager em, Class<?> entityClass) { if (em == null) { throw new IllegalArgumentException("EntityManager is null"); }/*from w ww . j a v a 2 s .com*/ EntityInfo entityInfo = CrudHelper.getEntityInfo(entityClass); String jpql = "from " + entityInfo.getEntityName(); return em.createQuery(jpql).getResultList(); }
From source file:org.jdal.dao.jpa.JpaUtils.java
/** * Result count from a CriteriaQuery/* w ww . j a v a 2s . c om*/ * @param em Entity Manager * @param criteria Criteria Query to count results * @return row count */ public static <T> Long count(EntityManager em, CriteriaQuery<T> criteria) { return em.createQuery(countCriteria(em, criteria)).getSingleResult(); }