Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8220745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:38:33+00:00 2026-06-07T13:38:33+00:00

PersistenceHelper-context.xml <bean id=dataSource class=org.springframework.jdbc.datasource.DriverManagerDataSource> <!—-> <property name=driverClassName value=org.hsqldb.jdbc.JDBCDriver/> <property name=url value=jdbc:hsqldb:mem:mydb/> <property name=username value=sa/>

  • 0

PersistenceHelper-context.xml

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">    <!---->
        <property name="driverClassName" value="org.hsqldb.jdbc.JDBCDriver"/>
        <property name="url" value="jdbc:hsqldb:mem:mydb"/>
        <property name="username" value="sa"/>
        <property name="password" value=""/>
    </bean>

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
          depends-on="dataSource" name="_sessFac" >  
        <property name="dataSource" ref="dataSource"/>
        <property name="configLocation" value="hibernate.cfg.xml.incDTD"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">create</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.connection.shutdown">true</prop>
            </props>
        </property>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>

class header

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:PersistenceHelper-context.xml"})
@TransactionConfiguration(defaultRollback = true, transactionManager = "transactionManager") 
@Transactional
public class BaseClass extends BaseTestClass{//.....}

And then all of my classes that I want to use transactions all derive from BaseClass, i.e.
public class FooTest extends BaseClass

Also, when I run my code, I see the following:

HibernateTransactionManager | Initiating transaction rollback
[13 Jul 2012 11:29:13,738] DEBUG  HibernateTransactionManager | Rolling back Hibernate transaction on Session [org.hibernate.impl.SessionImpl@107536b]
[13 Jul 2012 11:29:13,738] DEBUG  HibernateTransactionManager | Triggering afterCompletion synchronization
[13 Jul 2012 11:29:13,738] DEBUG  TransactionSynchronizationManager | Clearing transaction synchronization
[13 Jul 2012 11:29:13,738] DEBUG  TransactionSynchronizationManager | Removed value [org.springframework.orm.hibernate3.SessionHolder@17b3cdb] for key [org.hibernate.impl.SessionFactoryImpl@14642ac] from thread [main]
[13 Jul 2012 11:29:13,738] DEBUG  TransactionSynchronizationManager | Removed value [org.springframework.jdbc.datasource.ConnectionHolder@129a6a3] for key [org.springframework.jdbc.datasource.DriverManagerDataSource@c506b] from thread [main]
[13 Jul 2012 11:29:13,738] DEBUG  HibernateTransactionManager | Closing Hibernate Session [org.hibernate.impl.SessionImpl@107536b] after transaction
[13 Jul 2012 11:29:13,738] DEBUG  SessionFactoryUtils       | Closing Hibernate Session
[13 Jul 2012 11:29:13,738] INFO   TransactionalTestExecutionListener | Rolled back transaction after test execution for test context

Yet when I delete from my database, the change is persisted and my future tests fail because there is a missing object from the table. Am I missing something? Any direction would be much appreciated. Thanks in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:38:35+00:00Added an answer on June 7, 2026 at 1:38 pm

    You should use sessionFactory.getCurrentSession() to get a Session associated with the current transaction.

    openSession() creates a new session, and that session has nothing to do with transactions managed by Spring.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to follow this approach to create a datasource for embedded glassfish. The
I am using Hibernate 3 and Spring 3. I have been trying to populate
I have the following code that defines a getParts method to find a given
I deployed my application to the official server and started getting this error: Stacktrace:
I randomly see the same error in the catalina.out log: WARNING: SQL Error: 0,
I'm facing a particular line that is 153 characters long. Now, I tend to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.