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 4265314
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T06:36:27+00:00 2026-05-21T06:36:27+00:00

i have a small maven project with <artifactId>spring-core</artifactId> <artifactId>spring-test</artifactId> <artifactId>spring-beans</artifactId> <artifactId>spring-context</artifactId> <artifactId>spring-aop</artifactId> <artifactId>spring-context-support</artifactId> <artifactId>spring-tx</artifactId>

  • 0

i have a small maven project with

            <artifactId>spring-core</artifactId>
            <artifactId>spring-test</artifactId>
            <artifactId>spring-beans</artifactId>
            <artifactId>spring-context</artifactId>
            <artifactId>spring-aop</artifactId>
            <artifactId>spring-context-support</artifactId>
            <artifactId>spring-tx</artifactId>
            <artifactId>spring-orm</artifactId>  
            <artifactId>spring-web</artifactId>
            <artifactId>spring-webmvc</artifactId>
            <artifactId>spring-asm</artifactId>
            <artifactId>log4j</artifactId>
            <artifactId>hibernate-core</artifactId>
            <artifactId>hibernate-cglib-repack</artifactId>
            <artifactId>hsqldb</artifactId>


    <spring.version>3.0.5.RELEASE</spring.version>
    <hibernate.version>3.6.1.Final</hibernate.version>
    <hibernate-cglig-repack.version>2.1_3</hibernate-cglig-repack.version>
    <log4j.version>1.2.14</log4j.version>
    <javax-servlet-api.version>2.5</javax-servlet-api.version>
    <hsqldb.version>1.8.0.10</hsqldb.version>
    <mysql-connector.version>5.1.6</mysql-connector.version>
    <slf4j-log4j12.version>1.5.2</slf4j-log4j12.version>
    <slf4j-api.version>1.5.8</slf4j-api.version>
    <javaassist.version>3.7.ga</javaassist.version>

here is my applicationContext :

    <context:component-scan base-package="com.project.personal.admin.model"/>
<context:annotation-config />

<bean id="propertyconfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:mysql.hibernate.properties</value>
            <value>classpath:mysql.jdbc.properties</value>
        </list>
    </property>
</bean>
<context:annotation-config/>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}"  />
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="hibernateProperties">
        <props>

            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
            <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto}</prop>
        </props>
    </property>
    <property name="packagesToScan" value="com.project.personal.admin.model.domain" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

mysql.hibernate.properties

hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.format_sql=true
hibernate.hbm2ddl.auto=create

here is a small test class

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"classpath:META-INF/test-project-admin-config.xml"})
@TransactionConfiguration(defaultRollback=true)
@Transactional
public class UserDAOImplTest {

  @Resource(name="manager")
  Manager manager;

  @Autowired
  UserDAO userDAO;

  public UserDAOImplTest() {
  }



@Test
public void testSave() {
    User u1 = manager.CreateUser();
   //.....
    userDAO.save(u1);
    User expResult = u1;

    User result = (User)userDAO.getById(u1.getId());

    Assert.assertEquals(expResult, result);
    Assert.assertEquals(expResult.getId(), result.getId());

}

@Test
public void testUpdate(){

    User u2 = manager.CreateUser();
    //....
    u2.setPassword("mypassword");
    userDAO.save(u2);

    User fromdb =(User) userDAO.getById(u2.getId());

    fromdb.setEmail("claud@somemail.com");
    userDAO.save(fromdb);

    User result = (User) userDAO.getById(fromdb.getId());

    Assert.assertNotNull(result);
    Assert.assertEquals(fromdb.getEmail(), result.getEmail());

}

}

So far everything runs file test are successfull, but just that there is not sql output, i’m wondering what might have caused that.Since this is the first time i’m relying on trasactionConfiguration i thought it’s might be the cause of sql not showing other than that other previous project show the sql.

How can i address it as in forcing the show of the sql scripts(not using log4j yet)
thanks for reading.

  • 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-05-21T06:36:28+00:00Added an answer on May 21, 2026 at 6:36 am

    You use

    @TransactionConfiguration(defaultRollback=true) 
    @Transactional 
    

    Since your transactions are rolled back by default, it’s possbile that Hibernate doesn’t execute any SQL statements, because session flush doesn’t happen before rollback.

    You can disable rollback of test transactions by setting defaultRollback = false (or @Rollback(false) at method level).

    If you want Hibernate to issue real SQL statements, but don’t want to commit your test transactions, you can call flush() at the end of your test methods.

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

Sidebar

Related Questions

I have a small command line utility project that I'm using Maven to manage.
I have small project consisting of one maven project and two maven modules. One
I have configured a Maven build for a very small GWT project I'm having.
I mainly develop a big Web project with Java, Maven, and Spring. However, there
I have a small Java/Spring MVC REST /Maven app that runs just fine in
I have following Maven projects set up: PM-Core PM-Web (with a dependency to PM-Core)
I have a small maven project that build a java jar file. I added
I have small problem with Spring MVC. Basically what I'm trying to do is
I have small test app: Socket socket = new Socket(jeck.ru, 80); PrintWriter pw =
I have small web app that generate PDF files as a report. I'm trying

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.