List of usage examples for javax.persistence Query setFlushMode
Query setFlushMode(FlushModeType flushMode);
From source file:com.sun.socialsite.business.impl.JPAPersistenceStrategy.java
/** * Create query from queryString with FlushModeType.COMMIT * @param queryString the quuery/*from ww w . j av a2s. co m*/ * @throws SocialSiteException on any error */ public Query getDynamicQuery(String queryString) throws SocialSiteException { EntityManager em = getEntityManager(false); Query q = em.createQuery(queryString); // Never flush for queries. SocialSite code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:com.sun.socialsite.business.impl.JPAPersistenceStrategy.java
/** * Get named query with FlushModeType.COMMIT * @param queryName the name of the query * @throws SocialSiteException on any error *///from w ww . j av a 2 s . c o m public Query getNamedQuery(String queryName) throws SocialSiteException { EntityManager em = getEntityManager(false); Query q = em.createNamedQuery(queryName); // Never flush for queries. SocialSite code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:com.expressui.sample.dao.PermissionDao.java
public List<Permission> findByRoleEntityTypeAndField(AbstractRole role, String entityType, String field) { Query query = getEntityManager().createQuery("SELECT p FROM Permission p WHERE p.role = :role" + " AND p.entityType = :entityType AND p.field = :field"); query.setParameter("role", role); query.setParameter("entityType", entityType); query.setParameter("field", field); query.setFlushMode(FlushModeType.COMMIT); return query.getResultList(); }
From source file:com.expressui.core.dao.security.PermissionDao.java
/** * Finds permissions for a given role, entity type and field. * * @param role the role to query//from w w w . java 2s.com * @param entityType the entity type to query * @param field the field to query * @return found permissions */ public List<Permission> findByRoleEntityTypeAndField(Role role, String entityType, String field) { Query query = getEntityManager().createQuery("SELECT p FROM Permission p WHERE p.role = :role" + " AND p.targetType = :entityType AND p.field = :field"); query.setParameter("role", role); query.setParameter("entityType", entityType); query.setParameter("field", field); query.setFlushMode(FlushModeType.COMMIT); return query.getResultList(); }
From source file:com.healthcit.cacure.dao.FormElementDao.java
/** * If the description list of a source element was changed, * this ensures that the description(s) of its associated LinkElements is up-to-date. */// www . j ava 2 s .c o m public void updateAllFormElementsWithDescriptionChanged(FormElement formElement) { Iterator<Description> newDescriptionIterator = formElement.getDescriptionList().iterator(); while (newDescriptionIterator.hasNext()) { Description newDescription = newDescriptionIterator.next(); if (!newDescription.isNew()) { Query query = em.createNativeQuery( "update form_element set description = :desc from description d where form_element.link_id=:uuid and form_element.description = d.source_description_text and d.id = :id"); query.setParameter("desc", newDescription.getDescription()); query.setParameter("uuid", formElement.isLink() && !formElement.isExternalQuestion() ? ((LinkElement) formElement).getSourceId() : formElement.getUuid()); query.setParameter("id", newDescription.getId()); query.setFlushMode(FlushModeType.COMMIT); query.executeUpdate(); } } }
From source file:org.apache.roller.planet.business.jpa.JPAPersistenceStrategy.java
/** * Get named query with FlushModeType.COMMIT * @param queryName the name of the query * @throws org.apache.roller.planet.PlanetException on any error *//*from w ww . ja va 2s.c o m*/ public Query getNamedQuery(String queryName) throws PlanetException { EntityManager em = getEntityManager(false); Query q = em.createNamedQuery(queryName); // Never flush for queries. Roller code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:org.apache.roller.planet.business.jpa.JPAPersistenceStrategy.java
/** * Create query from queryString with FlushModeType.COMMIT * @param queryString the quuery/* w ww . ja v a 2 s. c o m*/ * @throws org.apache.roller.planet.PlanetException on any error */ public Query getDynamicQuery(String queryString) throws PlanetException { EntityManager em = getEntityManager(false); Query q = em.createQuery(queryString); // Never flush for queries. Roller code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.java
/** * Get named query with FlushModeType.COMMIT * @param queryName the name of the query * @throws org.apache.roller.weblogger.WebloggerException on any error *//* w w w . j a v a2s .c o m*/ public Query getNamedQuery(String queryName) throws WebloggerException { EntityManager em = getEntityManager(false); Query q = em.createNamedQuery(queryName); // Never flush for queries. Roller code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy.java
/** * Create query from queryString with FlushModeType.COMMIT * @param queryString the quuery//from ww w . j av a2s .co m * @throws org.apache.roller.weblogger.WebloggerException on any error */ public Query getDynamicQuery(String queryString) throws WebloggerException { EntityManager em = getEntityManager(false); Query q = em.createQuery(queryString); // Never flush for queries. Roller code assumes this behavior q.setFlushMode(FlushModeType.COMMIT); return q; }
From source file:org.easy.criteria.QueryProperties.java
public void applyProperties(Query query) { if (flashMode != null) { log.debug("flashMode = " + flashMode); query.setFlushMode(flashMode); }//from w w w.j av a 2 s .com if (lockMode != null) { log.debug("lockMode = " + lockMode); query.setLockMode(lockMode); } if (hintKey != null) { log.debug("hintKey = " + hintKey); log.debug("hintValue = " + hintValue); query.setHint(hintKey, hintValue); } if (startIndex >= 0 && maxResult > 0) { log.debug("startIndex = " + startIndex * maxResult); query.setFirstResult(startIndex * maxResult); } if (maxResult > 0) { log.debug("maxResult = " + maxResult); query.setMaxResults(maxResult); } }