Do Spring transactions propagate through new instantiations -


i'm working on bunch of legacy code written people before me , i'm confused particular kind of setup , wonder if has ever worked begin with.

there managed bean in spring has transactional method.

  @transactional(propagation = propagation.requires_new, rollbackfor = throwable.class)   public boolean updatedraftandlivepublicationusingfastdocumentsofmysite(list<fastdocumentlite> fastdocumentlites, long mysiteid) throws exception { ... } 

now inside method find new instantiations calling update methods fe:

 boolean firstfeed = new mysiteidupdate(publishing, sitedao, sitedomainservice).update(siteid, fastdocumentlites.get(0).getmysiteid()); 

from understanding on ioc new class isn't managed spring , it's variable in bean. going further inside update method see service gets called.

  @transactional(propagation=propagation.required, rollbackfor=throwable.class)   public void activatesubdomainforsite(long siteid, boolean activationofsite) 

so if there transaction open should propagated service. here don't if mysiteidupdate object isn't managed spring first transaction move forward activatesubdomainforsite method ?? or transaction being opened here. looked in logs , believe latter rather ask experts second oppinion before proclame legacy code complete rubbish project lead. i'm suffering stalestateexception somewhere further down road , i'm hoping has it.

i think code correct, , second @transactional should reuse existing transaction.

because:

1) spring transaction handling done either proxies or aspectj advices. if done proxies required mysiteidupdate invoke instance injected (this did). if use aspectj, should work anyway.

2) association transactions code use done thread, mean, long "are" in thread started transaction can use it. (you not start new thread, should work)


an other way explain: perfect legal when have method in call hierarchy not belong spring bean. should not make transaction handling fail.


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -