Package org.springframework.orm.hibernate4

Examples of org.springframework.orm.hibernate4.HibernateTransactionManager


    DataSource dataSource = getDataSource();
    populateDataBase(dataSource);
    sessionFactory = getSessionFactory(dataSource);
    hibernateTemplate = new HibernateTemplate(sessionFactory);
    hibernateTemplate.setCheckWriteOperations(false);
    HibernateTransactionManager tm = new HibernateTransactionManager(sessionFactory);
    hibernateListener = new HibernateFlowExecutionListener(sessionFactory, tm);

    ClassPathResource res = new ClassPathResource("flow-managed-persistence.xml", getClass());
    DefaultFlowModelHolder holder = new DefaultFlowModelHolder(new XmlFlowModelBuilder(res));
    FlowModelFlowBuilder builder = new FlowModelFlowBuilder(holder);
View Full Code Here


    populateDataBase(dataSource);
    jdbcTemplate = new JdbcTemplate(dataSource);
    sessionFactory = getSessionFactory(dataSource);
    hibernateTemplate = new HibernateTemplate(sessionFactory);
    hibernateTemplate.setCheckWriteOperations(false);
    HibernateTransactionManager tm = new HibernateTransactionManager(sessionFactory);
    hibernateListener = new HibernateFlowExecutionListener(sessionFactory, tm);
  }
View Full Code Here

    final OpenSessionInViewFilter filter2 = new OpenSessionInViewFilter();
    filter2.init(filterConfig2);

    final FilterChain filterChain = new FilterChain() {
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
        HibernateTransactionManager tm = new HibernateTransactionManager(sf);
        TransactionStatus ts = tm.getTransaction(
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
        org.hibernate.Session sess = SessionFactoryUtils.getSession(sf, true);
        SessionFactoryUtils.releaseSession(sess, sf);
        tm.commit(ts);

        sessionControl.verify();
        sessionControl.reset();

        session.close();
        sessionControl.setReturnValue(null, 1);
        sessionControl.replay();

        servletRequest.setAttribute("invoked", Boolean.TRUE);
      }
    };

    final FilterChain filterChain2 = new FilterChain() {
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
          throws IOException, ServletException {

        HibernateTransactionManager tm = new HibernateTransactionManager(sf2);
        TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
        tm.commit(ts);

        session2Control.verify();
        session2Control.reset();

        session2.close();
View Full Code Here

    final OpenSessionInViewFilter filter2 = new OpenSessionInViewFilter();
    filter2.init(filterConfig2);

    final FilterChain filterChain = new FilterChain() {
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
        HibernateTransactionManager tm = new HibernateTransactionManager(sf);
        TransactionStatus ts = tm.getTransaction(
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
        org.hibernate.Session sess = SessionFactoryUtils.getSession(sf, true);
        SessionFactoryUtils.releaseSession(sess, sf);
        tm.commit(ts);

        sessionControl.verify();
        sessionControl.reset();
        try {
          session.close();
View Full Code Here

        .buildSessionFactory();
  }

  @Bean
  public PlatformTransactionManager transactionManager() throws Exception {
    return new HibernateTransactionManager(sessionFactory());
  }
View Full Code Here

    filter2.init(filterConfig2);

    final FilterChain filterChain = new FilterChain() {
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
        HibernateTransactionManager tm = new HibernateTransactionManager(sf);
        TransactionStatus ts = tm.getTransaction(
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
        org.hibernate.Session sess = SessionFactoryUtils.getSession(sf, true);
        SessionFactoryUtils.releaseSession(sess, sf);
        tm.commit(ts);
        servletRequest.setAttribute("invoked", Boolean.TRUE);
      }
    };

    final FilterChain filterChain2 = new FilterChain() {
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse)
        throws IOException, ServletException {
        HibernateTransactionManager tm = new HibernateTransactionManager(sf2);
        TransactionStatus ts = tm.getTransaction(new DefaultTransactionDefinition());
        tm.commit(ts);
        filter.doFilter(servletRequest, servletResponse, filterChain);
      }
    };

    FilterChain filterChain3 = new PassThroughFilterChain(filter2, filterChain2);
View Full Code Here

    filter2.init(filterConfig2);

    final FilterChain filterChain = new FilterChain() {
      @Override
      public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) {
        HibernateTransactionManager tm = new HibernateTransactionManager(sf);
        TransactionStatus ts = tm.getTransaction(
            new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_SUPPORTS));
        org.hibernate.Session sess = SessionFactoryUtils.getSession(sf, true);
        SessionFactoryUtils.releaseSession(sess, sf);
        tm.commit(ts);
        servletRequest.setAttribute("invoked", Boolean.TRUE);
      }
    };

    FilterChain filterChain2 = new FilterChain() {
View Full Code Here

    @Bean
    @Autowired
    public HibernateTransactionManager transactionManager(SessionFactory sessionFactory)
    {
        HibernateTransactionManager htm = new HibernateTransactionManager();
        htm.setSessionFactory(sessionFactory);
        return htm;
    }
View Full Code Here

  @SuppressWarnings({ "rawtypes", "unchecked"})
  private void reindex(final Class< ? > clazz, final ReindexSettings settings, final StringBuffer buf)
  {
    // PF-378: Performance of run of full re-indexing the data-base is very slow for large data-bases
    // Single transactions needed, otherwise the full run will be very slow for large data-bases.
    final TransactionTemplate tx = new TransactionTemplate(new HibernateTransactionManager(hibernate.getSessionFactory()));
    tx.execute(new TransactionCallback() {
      // The call-back is needed, otherwise a lot of transactions are left open until last run is completed:
      public Object doInTransaction(final TransactionStatus status)
      {
        try {
View Full Code Here

   * @param includeHistory bei false werden die History Einträge nicht geschrieben
   * @param preserveIds If true, the object ids will be preserved, otherwise new ids will be assigned through xstream.
   */
  public void dumpDatabaseToXml(final Writer writer, final boolean includeHistory, final boolean preserveIds)
  {
    final TransactionTemplate tx = new TransactionTemplate(new HibernateTransactionManager(hibernate.getSessionFactory()));
    tx.execute(new TransactionCallback() {
      public Object doInTransaction(final TransactionStatus status)
      {
        hibernate.execute(new HibernateCallback() {
          public Object doInHibernate(final Session session) throws HibernateException
View Full Code Here

TOP

Related Classes of org.springframework.orm.hibernate4.HibernateTransactionManager

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.