Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring 3.0.5 + hibernate 3.6 hibernate.show_sql not showing.Is it due to use of transaction?
    primarykey
    data
    text
    <p>i have a small maven project with </p> <pre><code> &lt;artifactId&gt;spring-core&lt;/artifactId&gt; &lt;artifactId&gt;spring-test&lt;/artifactId&gt; &lt;artifactId&gt;spring-beans&lt;/artifactId&gt; &lt;artifactId&gt;spring-context&lt;/artifactId&gt; &lt;artifactId&gt;spring-aop&lt;/artifactId&gt; &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt; &lt;artifactId&gt;spring-tx&lt;/artifactId&gt; &lt;artifactId&gt;spring-orm&lt;/artifactId&gt; &lt;artifactId&gt;spring-web&lt;/artifactId&gt; &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt; &lt;artifactId&gt;spring-asm&lt;/artifactId&gt; &lt;artifactId&gt;log4j&lt;/artifactId&gt; &lt;artifactId&gt;hibernate-core&lt;/artifactId&gt; &lt;artifactId&gt;hibernate-cglib-repack&lt;/artifactId&gt; &lt;artifactId&gt;hsqldb&lt;/artifactId&gt; &lt;spring.version&gt;3.0.5.RELEASE&lt;/spring.version&gt; &lt;hibernate.version&gt;3.6.1.Final&lt;/hibernate.version&gt; &lt;hibernate-cglig-repack.version&gt;2.1_3&lt;/hibernate-cglig-repack.version&gt; &lt;log4j.version&gt;1.2.14&lt;/log4j.version&gt; &lt;javax-servlet-api.version&gt;2.5&lt;/javax-servlet-api.version&gt; &lt;hsqldb.version&gt;1.8.0.10&lt;/hsqldb.version&gt; &lt;mysql-connector.version&gt;5.1.6&lt;/mysql-connector.version&gt; &lt;slf4j-log4j12.version&gt;1.5.2&lt;/slf4j-log4j12.version&gt; &lt;slf4j-api.version&gt;1.5.8&lt;/slf4j-api.version&gt; &lt;javaassist.version&gt;3.7.ga&lt;/javaassist.version&gt; </code></pre> <p>here is my applicationContext :</p> <pre><code> &lt;context:component-scan base-package="com.project.personal.admin.model"/&gt; &lt;context:annotation-config /&gt; &lt;bean id="propertyconfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;classpath:mysql.hibernate.properties&lt;/value&gt; &lt;value&gt;classpath:mysql.jdbc.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;context:annotation-config/&gt; &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt; &lt;property name="driverClassName" value="${jdbc.driverClassName}" /&gt; &lt;property name="url" value="${jdbc.url}" /&gt; &lt;property name="username" value="${jdbc.username}" /&gt; &lt;property name="password" value="${jdbc.password}" /&gt; &lt;/bean&gt; &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"&gt; &lt;property name="dataSource" ref="dataSource" /&gt; &lt;property name="hibernateProperties"&gt; &lt;props&gt; &lt;prop key="hibernate.dialect"&gt;${hibernate.dialect}&lt;/prop&gt; &lt;prop key="hibernate.show_sql"&gt;${hibernate.show_sql}&lt;/prop&gt; &lt;prop key="hibernate.format_sql"&gt;${hibernate.format_sql}&lt;/prop&gt; &lt;prop key="hibernate.hbm2ddl.auto"&gt;${hibernate.hbm2ddl.auto}&lt;/prop&gt; &lt;/props&gt; &lt;/property&gt; &lt;property name="packagesToScan" value="com.project.personal.admin.model.domain" /&gt; &lt;/bean&gt; &lt;bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"&gt; &lt;property name="sessionFactory" ref="sessionFactory" /&gt; &lt;/bean&gt; </code></pre> <p>mysql.hibernate.properties</p> <pre><code>hibernate.dialect=org.hibernate.dialect.MySQLDialect hibernate.show_sql=true hibernate.format_sql=true hibernate.hbm2ddl.auto=create </code></pre> <p>here is a small test class </p> <pre><code>@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()); } </code></pre> <p>}</p> <p>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.</p> <p>How can i address it as in forcing the show of the sql scripts(not using log4j yet) thanks for reading.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload