Announcement Announcement Module
Collapse
No announcement yet.
READ_UNCOMMITED not working. Please help Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • READ_UNCOMMITED not working. Please help

    Hi there,

    I am working on a web project (spring 2.5.6, hibernate 3.2, tomcat 6, mysql 5.1) that uses some services that have to run within a READ_UNCOMMITED transaction but it doesn't work properly.


    I have a N:M relationship between some users that have accounts...

    USER table

    id - name - ...

    ACCOUNT table

    id - money - ...

    USER_ACCOUNT table

    id_user - id_account


    ... and I need that concurrent users working on the same account notice the uncommited changes but it doesn't work as expected.


    My DAOS use HibernateTemplate and don't have any transactional behaviour declared:

    e.g:

    Code:
    public class AccountDAO extends HibernateDaoSupport {
    
    	...	
    
    	public Account findById(java.lang.Integer id) {
    		log.debug("getting Account instance with id: " + id);
    		try {
    			Account instance = (Account ) getHibernateTemplate()
    					.get("com.iberservices.hibernate.Account", id);
    			return instance;
    		} catch (RuntimeException re) {
    			log.error("get failed", re);
    			throw re;
    		}
    	}
    
    	...
    My business service is declared as follows (I've made the configuration in the application-context.xml property: tx:annotation-driven, transactionManager and so on):

    Code:
    @Transactional(isolation=Isolation.READ_UNCOMMITTED)
    private void updateMoney(Integer idAccount, float money) {
    	
    	//1 LOAD USER ACCOUNT
    	Account cb = accountDAO.findById(idAccount);
    	//2 LOAD USER ACCOUNT
    	Float moneyInAccount = cb.getMoney();
    	//3 MODIFY MONEY IN ACCOUNT
    	moneyInAccount = moneyInAccount+money;
    	cb.setMoney(moneyInAccount);
    	//4 UPDATE ACCOUNT
    	accountDAO.attachDirty(cb);
    	//5 ACCOUNT UPDATED
    	log.debug("ACCOUNT UPDATED");
    
    }
    I want to read the uncommited changes made by a concurrent user. However I can't get that behaviour:

    1) I'm debugging web application to test it
    2) I start a transaction and step until //5 ACCOUNT UPDATED
    3) I start another transaction from another web navigator and step until it reads the same Account (after //1 LOAD USER ACCOUNT) However it doesn't read the uncommited changes !?!?!?

    Any idea why it isn't working???

    Thanks in advance,

    Jose

  • #2
    Help!

    Still having this problem!

    I'd really appreciate some help

    Comment

    Working...
    X