Hi There,
I'm testing out my persistence layer in a small console application before moving it to the webapp. I am using Spring 3.x and Hibernate 3.x and using Java 6 with PostgreSQL 8.4.
PROBLEM : I'm able to persist and recover the data BUT unable to commit the transaction using the declarative Tx support.
@Transactional annotations and <tx:annotation-driven/>
Here's my DAO.
I am actually able to save and retrieve the record back from the DB and I see that Hibernate is issuing the right SQL while persisting and retrieving it BUT the problem is that the DATA is NOT committed to the disk(I confirm that by going to psql and issuing a query to the same table). I am NOT seeing a commit statement from Hibernate. Just to be sure, I tried to insert the record myself directly using psql and it committed the record just fine. So, I'm sure that there are NO issues with PostgreSQL itself.Code:@Transactional public class AddressesDAO extends HibernateDaoSupport { @Transactional public void save(Addresses transientInstance) { log.debug("saving Addresses instance"); try { getHibernateTemplate().save(transientInstance); log.debug("save successful"); } catch (RuntimeException re) { log.error("save failed", re); throw re; } } @Transactional(readOnly = true) public Addresses findById(java.lang.Integer id) { log.debug("getting Addresses instance with id: " + id); try { Addresses instance = (Addresses) getHibernateTemplate().get( "com.vattikutiirf.hibernatespring.Addresses", id); return instance; } catch (RuntimeException re) { log.error("get failed", re); throw re; } } }
How do I debug this problem ?
Thank you,
BR,
~A
Here's my spring config file.
Code:<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> <property name="configLocation" value="file:src/hibernate.cfg.xml"> </property> </bean> <bean id="AddressesDAO" class="com.vattikutiirf.hibernatespring.AddressesDAO"> <property name="sessionFactory"> <ref bean="sessionFactory" /> </property> </bean> <bean id="persistenceLayer" class="com.vattikutiirf.hibernatespring.PersistenceLayer"> <property name="addressesDAO"> <ref bean="AddressesDAO" /> </property> </bean> <!-- enable the configuration of transactional behavior based on annotations --> <tx:annotation-driven /> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> </beans>


Reply With Quote
