[jboss-user] [JBossCache] - Re: how to support treecache transaction in CMT
bstansberry@jboss.com
do-not-reply at jboss.com
Mon Aug 21 10:36:59 EDT 2006
Was just about to say that looks fine too, when I saw the problem :)
The fact that you put your Person object in the cache doesn't make the Person object transactional. You are changing the person object by changing the address -- that change won't roll back.
To get what you want you'd need something more like:
| if("add".equals(command)){
| Person old = ((Person)cache.get("/test/p1","p1"));
| Person clone = (Person) old.clone();
| Address oldAdd = clone.getAddress();
| Address addClone = (Address) oldAdd.clone();
| addClone.setCity(value);
| clone.setAddress(addClone);
| cache.put("/test/a1","a1" ,clone);
|
| if("pp".equals(key)){
| System.out.println("Gettttttttttttttbefore:a1=" + cache.get("/test/a1","a1"));
| throw new Exception("throw exception for rollback");
| }
|
| }
Usual warning that above code is for illustration, may not compile, etc.
To have changes to your objects be transactional, you'd need to use PojoCache and instrument your classes.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966456#3966456
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966456
More information about the jboss-user
mailing list