Tabnine Logo
HibernateTemplate.executeWithNativeSession
Code IndexAdd Tabnine to your IDE (free)

How to use
executeWithNativeSession
method
in
org.springframework.orm.hibernate5.HibernateTemplate

Best Java code snippets using org.springframework.orm.hibernate5.HibernateTemplate.executeWithNativeSession (Showing top 20 results out of 315)

origin: spring-projects/spring-framework

@Override
public void deleteAll(final Collection<?> entities) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    for (Object entity : entities) {
      session.delete(entity);
    }
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
@Nullable
public <T> T get(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode)
    throws DataAccessException {
  return executeWithNativeSession(session -> {
    if (lockMode != null) {
      return session.get(entityClass, id, new LockOptions(lockMode));
    }
    else {
      return session.get(entityClass, id);
    }
  });
}
origin: spring-projects/spring-framework

@Override
public boolean contains(final Object entity) throws DataAccessException {
  Boolean result = executeWithNativeSession(session -> session.contains(entity));
  Assert.state(result != null, "No contains result");
  return result;
}
origin: spring-projects/spring-framework

@Override
public void evict(final Object entity) throws DataAccessException {
  executeWithNativeSession(session -> {
    session.evict(entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void clear() throws DataAccessException {
  executeWithNativeSession(session -> {
    session.clear();
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public Serializable save(final String entityName, final Object entity) throws DataAccessException {
  return nonNull(executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    return session.save(entityName, entity);
  }));
}
origin: spring-projects/spring-framework

@Override
public void saveOrUpdate(final Object entity) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.saveOrUpdate(entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void replicate(final String entityName, final Object entity, final ReplicationMode replicationMode)
    throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.replicate(entityName, entity, replicationMode);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void replicate(final Object entity, final ReplicationMode replicationMode)
    throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.replicate(entity, replicationMode);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void persist(final String entityName, final Object entity) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.persist(entityName, entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void persist(final Object entity) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.persist(entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Deprecated
@Override
@SuppressWarnings({"rawtypes", "unchecked", "deprecation"})
public List<?> findByValueBean(final String queryString, final Object valueBean)
    throws DataAccessException {
  return nonNull(executeWithNativeSession((HibernateCallback<List<?>>) session -> {
    org.hibernate.Query queryObject = queryObject(
        ReflectionUtils.invokeMethod(createQueryMethod, session, queryString));
    prepareQuery(queryObject);
    queryObject.setProperties(valueBean);
    return queryObject.list();
  }));
}
origin: spring-projects/spring-framework

@Override
public void delete(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    if (lockMode != null) {
      session.buildLockRequest(new LockOptions(lockMode)).lock(entity);
    }
    session.delete(entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void delete(final String entityName, final Object entity, @Nullable final LockMode lockMode)
    throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    if (lockMode != null) {
      session.buildLockRequest(new LockOptions(lockMode)).lock(entityName, entity);
    }
    session.delete(entityName, entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public Object load(final String entityName, final Serializable id, @Nullable final LockMode lockMode)
    throws DataAccessException {
  return nonNull(executeWithNativeSession(session -> {
    if (lockMode != null) {
      return session.load(entityName, id, new LockOptions(lockMode));
    }
    else {
      return session.load(entityName, id);
    }
  }));
}
origin: spring-projects/spring-framework

@Override
public void lock(final String entityName, final Object entity, final LockMode lockMode)
    throws DataAccessException {
  executeWithNativeSession(session -> {
    session.buildLockRequest(new LockOptions(lockMode)).lock(entityName, entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
public void lock(final Object entity, final LockMode lockMode) throws DataAccessException {
  executeWithNativeSession(session -> {
    session.buildLockRequest(new LockOptions(lockMode)).lock(entity);
    return null;
  });
}
origin: spring-projects/spring-framework

@Override
@SuppressWarnings("unchecked")
public <T> T merge(final T entity) throws DataAccessException {
  return nonNull(executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    return (T) session.merge(entity);
  }));
}
origin: spring-projects/spring-framework

@Override
public <T> T load(final Class<T> entityClass, final Serializable id, @Nullable final LockMode lockMode)
    throws DataAccessException {
  return nonNull(executeWithNativeSession(session -> {
    if (lockMode != null) {
      return session.load(entityClass, id, new LockOptions(lockMode));
    }
    else {
      return session.load(entityClass, id);
    }
  }));
}
origin: spring-projects/spring-framework

@Override
public void update(final Object entity, @Nullable final LockMode lockMode) throws DataAccessException {
  executeWithNativeSession(session -> {
    checkWriteOperationAllowed(session);
    session.update(entity);
    if (lockMode != null) {
      session.buildLockRequest(new LockOptions(lockMode)).lock(entity);
    }
    return null;
  });
}
org.springframework.orm.hibernate5HibernateTemplateexecuteWithNativeSession

Javadoc

Execute the action specified by the given action object within a native Session.

This execute variant overrides the template-wide #isExposeNativeSession() setting.

Popular methods of HibernateTemplate

  • delete
  • save
  • <init>
    Create a new HibernateTemplate instance.
  • find
  • get
  • load
  • update
  • getSessionFactory
    Return the Hibernate SessionFactory that should be used to create Hibernate Sessions.
  • findByNamedParam
  • merge
  • afterPropertiesSet
  • createSessionProxy
    Create a close-suppressing proxy for the given Hibernate Session. The proxy also prepares returned Q
  • afterPropertiesSet,
  • createSessionProxy,
  • disableFilters,
  • doExecute,
  • enableFilters,
  • findByCriteria,
  • findByNamedQueryAndNamedParam,
  • getFilterNames,
  • isCheckWriteOperations

Popular in Java

  • Reactive rest calls using spring rest template
  • getExternalFilesDir (Context)
  • findViewById (Activity)
  • setScale (BigDecimal)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JPanel (javax.swing)
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now