Back Forum Reply New

Help on @Transactional (Spring 2.5.5 + Hibernate 3.2.6)

Folks,

I am having problem in making @Transactional, please suggest where i'm doing wrong.

All my objects are using annotations.

snippet from applicationContext.xml Code:
lt;bean id=quot;transactionManagerquot;class=quot;org..orm.hibernate3.HibernateTransactionManagerquot;
p:sessionFactory-ref=quot;sessionFactoryquot; /gt;
lt;context:annotation-config /gt;
lt;tx:annotation-driven/gt;
controller code

Code:
package com.ssk.scp.web.controller;@Controller
public class Application {

private static Log log = LogFactory.getLog(Application.class);

private ApplicationDao appDao;@RequestMapping(quot;/createApp.doquot;)
public String create(fromServletRequest request, Model model)
throws Exception {
RequestDataHelper dataHelper = new RequestDataHelper(requestData);

ApplicationXMLBuilder b = new ApplicationXMLBuilder(requestData);

String xml = b.build();

ApplicationData data = new ApplicationData();

...
...
appDao.save(data);

log.info(quot;Successfully saved application with id : quot; + data.getId());
return quot;homequot;;
}

public ApplicationDao getAppDao() {
return appDao;
}

@Autowired
public void setAppDao(ApplicationDao appDao) {
this.appDao = appDao;
}

}
DAo code

Code:
@Repository(quot;applicationDaoquot;)
@Transactional
public class ApplicationDaoImpl extends HibernateDaoSupport implements
ApplicationDao {

private static Log log = LogFactory.getLog(ApplicationDaoImpl.class);

@Autowired
public ApplicationDaoImpl(SessionFactory sessionFactory) {
this.setSessionFactory(sessionFactory);
}

@Transactional(readOnly = false)
public Long save(ApplicationData o) throws Exception {
getSessionFactory().getCurrentSession().save(o);
return o.getId();
}

}

Output when i save

Code:
[INFO,AccessController,from-8089-2] With in AccessController
[INFO,AccessController,from-8089-2] With in AccessController
Hibernate: select APPLICATION_DATA_ID_SEQ.nextval from dual
[INFO,ScpApplication,from-8089-2] Successfully saved application with id : 5600

everythign seems fine. no error but my database is not having any data with id being displayed in the output. Data is not committed!

What am i missing here. I cross verified with petclinic example and i couldnt able to pin point.

Pls help!

Thanks

i have encounting the same problems

but i use @transactional on service

I am testing to understand the concept but if you annote even Dao it should work right? I saw petclinic example directly calls Repository from within controller.

Anyone please help!

i have the same problems on @Transactional

showthread.php?t=65168

Seems to be related to hibernate!

I manually flush the session and I can see data in database.

Btw, I am using org..orm.hibernate3.support.OpenSes  sionInViewFilter due to my or designI configured various settings for hibernate session factory like

1) lt;prop key=quot;hibernate.transaction.flush_before_completion  quot;gt;truelt;/propgt;

2) lt;prop key=quot;hibernate.connection.release_modequot;gt;after_tran  sactionlt;/propgt;
, may be illogical for OpenSessionInViewFilter but none worked.

Any better way of configuring spring to flush session after transaction?

Thanks all
¥
Back Forum Reply New