Package org.springframework.orm.jpa

Examples of org.springframework.orm.jpa.JpaCallback


    });
  }

  @Transactional
  public void flush() {
    getJpaTemplate().execute(new JpaCallback() {
      public Object doInJpa(EntityManager entityManager)
          throws PersistenceException {
        entityManager.flush();
        return null;
      }
View Full Code Here


  }

 
  public int count() {
    logger.debug("count() called");
    return (Integer) getJpaTemplate().execute(new JpaCallback() {

      public Object doInJpa(EntityManager em) throws PersistenceException {
        Query query = createCountQuery(em);
        prepareQueryHintsIfNeeded(query);
        Number count = (Number) query.getSingleResult();
View Full Code Here

      sQuery = "SELECT instance FROM " + entityName + " instance";
    } else {
      sQuery =  "SELECT " + newSelectStatement + " FROM " + entityName + " o";
    }
    final String fQuery = sQuery;
    return (List<T>) getJpaTemplate().execute(new JpaCallback() {
      public Object doInJpa(EntityManager em) throws PersistenceException {
        Query query = em.createQuery(fQuery);
        prepareQueryHintsIfNeeded(query);
        return query.getResultList();
      }});
View Full Code Here


  private int executeCountQuery(final Group group,
      final String squery, final Criterion... criteria) {
    try {
      return (Integer) this.getJpaTemplate().execute(new JpaCallback() {
        public Object doInJpa(EntityManager em)
            throws PersistenceException {
          Query query = em.createQuery(squery.toString());
          if (criteria != null) {
            GenericDaoUtils.addGroupParams(query, group, null);
View Full Code Here

  @SuppressWarnings("unchecked")
  private List executeQueryWithJPA(final Criterion[] criteria,
      final int startPosition, final int maxResult, final Group group,
      final String sQuery) {
    try {
      return (List) this.getJpaTemplate().execute(new JpaCallback() {
        public Object doInJpa(EntityManager em)
            throws PersistenceException {
          Query query = em.createQuery(sQuery);
          if (criteria != null) {
            GenericDaoUtils.addGroupParams(query, group, null);
View Full Code Here

  }


  public Object executeFinder(final Method method, final Object[] queryArgs) {
    final String queryName = queryNameFromMethodName(method.getName());
    return getJpaTemplate().execute(new JpaCallback() {

      public Object doInJpa(EntityManager em) throws PersistenceException {
        Query query = em.createNamedQuery(queryName);
        int index = 1;
        for (Object arg : queryArgs) {
View Full Code Here

    });
  }

    public Object executeDelete(final Method method, final Object[] queryArgs) {
        final String queryName = queryNameFromMethodName(method.getName());
        return getJpaTemplate().execute(new JpaCallback() {

            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query query = em.createNamedQuery(queryName);
                int index = 1;
                for (Object arg : queryArgs) {
View Full Code Here

    }

    public Object executeUpdate(final Method method, final Object[] queryArgs) {
        final String methodName = method.getName();
        final String queryName = queryNameFromMethodName(methodName);
        return getJpaTemplate().execute(new JpaCallback() {
            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query query = em.createNamedQuery(queryName);
                int index = 0;
               
                for (Object arg : queryArgs) {
View Full Code Here

  @SuppressWarnings("unchecked")
  private T doReadPopulated(final PK id) {
    final String queryName = getEntityName()
        + ".readPopulated";
    return (T) getJpaTemplate().execute(new JpaCallback() {
      public Object doInJpa(EntityManager em) throws PersistenceException {
        Query query = em.createNamedQuery(queryName);
        query.setParameter(1, id);
        return query.getSingleResult();
      }
View Full Code Here

    return getEntityName() + "." + finderMethod;
  }

  @Transactional
  public void delete(final T entity) {
    getJpaTemplate().execute(new JpaCallback() {
      public Object doInJpa(EntityManager entityManager) throws PersistenceException {
        T managedEntity = entity;
        if (!entityManager.contains(managedEntity)) {
          managedEntity = entityManager.merge(entity);
        }
View Full Code Here

TOP

Related Classes of org.springframework.orm.jpa.JpaCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.