Package org.springframework.orm.jpa

Examples of org.springframework.orm.jpa.JpaCallback


     * @param till the max result raw
     * @param params query parameters
     * @return list of objects
     */
    public List<D> findByNamedParams(final String queryString, final int from, final int till, final Map<String, ?> params) {
        return executeFind(new JpaCallback() {

            @Override
            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query queryObject = em.createQuery(queryString);
                queryObject.setFirstResult(from);
View Full Code Here


     * @param queryString query
     * @param values query parameters
     * @return object or null if no object found
     */
    protected D findSingle(final String queryString, final Object... values) {
        return (D)execute(new JpaCallback() {

            @Override
            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query queryObject = em.createQuery(queryString);
                if (values != null) {
View Full Code Here

     * @param values query parameters
     * @return object or null if no object found
     */
    @Override
    public D findMaxOneObject(final String queryString, final Object... values) {
        return (D)execute(new JpaCallback() {

            @Override
            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query queryObject = em.createQuery(queryString);
                if (values != null) {
View Full Code Here

     * @param queryString query
     * @param params query parameters
     * @return object of null if no object found
     */
    public D findByNamedParamsSingle(final String queryString, final Map<String, ?> params) {
        return (D)execute(new JpaCallback() {

            @Override
            public Object doInJpa(EntityManager em) throws PersistenceException {
                Query queryObject = em.createQuery(queryString);
                if (params != null) {
View Full Code Here

    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    jpaTemplate = new JpaTemplate((EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY));

    txTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        Object result = jpaTemplate.execute(new JpaCallback() {
          public Object doInJpa(EntityManager em) throws PersistenceException {
            try {
              SpringSingleSessionCommandService.this.env.set(EnvironmentName.ENTITY_MANAGER, em);
              em.persist(sessionInfo);
              // update the session id to be the same as the session info id
View Full Code Here

    checkEnvironment(env);
    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    jpaTemplate = new JpaTemplate((EntityManagerFactory) env.get(EnvironmentName.ENTITY_MANAGER_FACTORY));
    txTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        return jpaTemplate.execute(new JpaCallback() {

          public Object doInJpa(EntityManager em) throws PersistenceException {
            try {
              SpringSingleSessionCommandService.this.env.set(EnvironmentName.ENTITY_MANAGER, em);
              sessionInfo = em.find(SessionInfo.class, sessionId);
View Full Code Here

    ksession.halt();

    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    T result = (T) txTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        T result = (T) jpaTemplate.execute(new JpaCallback() {
          public Object doInJpa(EntityManager em) {
            env.set(EnvironmentName.ENTITY_MANAGER, em);
            try {
              SessionInfo sessionInfoMerged = em.merge(sessionInfo);
              sessionInfoMerged.setJPASessionMashallingHelper(sessionInfo.getJPASessionMashallingHelper());
View Full Code Here

  public StatefulKnowledgeSession newStatefulKnowledgeSession() {
    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    return (StatefulKnowledgeSession) txTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        return getJpaTemplate().execute(new JpaCallback() {
          public StatefulKnowledgeSession doInJpa(EntityManager em) throws PersistenceException {
            return jpaKnowledgeServiceProvider.newStatefulKnowledgeSession(kbase, null, environment);
          }
        });
      }
View Full Code Here

 
  public StatefulKnowledgeSession loadStatefulKnowledgeSession(final int sessionId) {
    TransactionTemplate txTemplate = new TransactionTemplate(transactionManager);
    return (StatefulKnowledgeSession) txTemplate.execute(new TransactionCallback() {
      public Object doInTransaction(TransactionStatus status) {
        return getJpaTemplate().execute(new JpaCallback() {
          public StatefulKnowledgeSession doInJpa(EntityManager em) throws PersistenceException {
            return jpaKnowledgeServiceProvider.loadStatefulKnowledgeSession(sessionId, kbase, null, environment);
          }
        });
      }
View Full Code Here

    protected void poll() throws Exception {
        // must reset for each poll
        shutdownRunningTask = null;
        pendingExchanges = 0;

        template.execute(new JpaCallback() {
            public Object doInJpa(EntityManager entityManager) throws PersistenceException {
                Queue<DataHolder> answer = new LinkedList<DataHolder>();

                Query query = getQueryFactory().createQuery(entityManager);
                configureParameters(query);
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.