Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Object Relational Mapping
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Devaka Cooray
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Jeanne Boyarsky
Tim Cooke
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Mikalai Zaikin
Carey Brown
Bartenders:
Forum:
Object Relational Mapping
Hiberante transaction in Spring
Edward Chen
Ranch Hand
Posts: 798
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using
Tomcat
5.5, Oracle Express and Spring 2.6. Now I have problems in transaction. I did all setup, but transaction doesn't work.
<bean id="MtsDao" class="dao.MtsDaoImpl"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="mtsTxManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <bean id="MtsServiceTarget" class="service.MtsServiceImpl"> <property name="mtsDao" ref="MtsDao" /> </bean> <bean id="MtsService" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"> <property name="transactionManager" ref="mtsTxManager"/> <property name="target" ref="MtsServiceTarget"/> <property name="transactionAttributes"> <props> <prop key="increasePrice">PROPAGATION_REQUIRED</prop> <prop key="*">PROPAGATION_SUPPORTS,readOnly</prop> </props> </property> </bean> <!-- ///////////////// Hibernate /////////// --> <!-- DataSource Property --> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>oracle.jdbc.driver.OracleDriver</value> </property> <property name="url"> <value>jdbc :-o racle:thin:@localhost:1521/XE</value> </property> <property name="username" value="t" /> <property name="password" value="t" /> </bean> <!-- Database Property --> <bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="properties"> <props> <prop key="hibernate.hbm2ddl.auto">create</prop> <prop key="hibernate.dialect"> org.hibernate.dialect.OracleDialect </prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.c3p0.minPoolSize">5</prop> <prop key="hibernate.c3p0.maxPoolSize">20</prop> <prop key="hibernate.c3p0.timeout">600</prop> <prop key="hibernate.c3p0.max_statement">50</prop> <prop key="hibernate.c3p0.testConnectionOnCheckout"> false </prop> </props> </property> </bean> <!-- Hibernate SessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource"> <ref local="dataSource" /> </property> <property name="hibernateProperties"> <ref bean="hibernateProperties" /> </property> <property name="mappingResources"> <list> <value>project.hbm.xml</value> </list> </property> </bean>
In the Dao,
public void addPeople(String name){ People p = new People(); p.setTitle(name); Ticket t = new Ticket(); List ticketList = new ArrayList(); ticketList.add(t); p.setTicketList(ticketList); this.getHibernateTemplate().saveOrUpdate(p); }
In the service,
public void increasePrice() throws Exception { //System.out.println("---invoke dao, get result="+mtsDao.getPeople()); mtsDao.addPeople("manager4"); System.out.println("---throw excetpion, test transaction---"); if(true) throw new Exception("test transaction"); mtsDao.addPeople("staff4"); }
test
transaction. but failed, the data is not roll-back.
Any hints ?
Thanks.
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Srping+Hibernate bad configurated causing huge memory consumption
login form with database and spring security
spring 2 with hibernate 3
spring transaction management only
Connectin leak
More...