Spring transaction management ppt

transaction management in spring ppt and building web applications with spring mvc pdf
LexiWills Profile Pic
LexiWills,United Kingdom,Professional
Published Date:01-08-2017
Your Website URL(Optional)
Comment
Transaction  Management  with  Spring Bruce  CampbellNotes This  is  a  training  NOT  a  presenta4on • Please  ask  ques4ons • Prerequisites • – A  computerTransac4on  Management • ACID – Demo  Vanilla  JDBC – Spring  Transac4on  Management • Java  stack  configura4on – Programa4c – Demo  of  Transac4on  Template – Declara4ve – Local  vs  Global  &  JTA – Lab –Transac)on  ManagementACID  Transactions ACID  is  a  set  of  proper4es  that  define  the   • reliability  of  a  set  of  changes  (to  a  database) –Atomic  -­‐  all  or  nothing –Consistent  -­‐  results  are  valid –Isolated  -­‐  indicates  when  changes  become  visible –Durable  -­‐  changes  s4ck  no  maLer  whatACID  by  Example 10 My  Account Your  Account Transfer  funds  between  accounts • This  is  a  2-­‐step  process • – First,  remove  the  money  from  my  account  (debit) – Second,  add  the  money  to  your  account  (credit)Atomic 10 My  Account Your  Account Two-­‐Step  Process 1.  Debit  my  account 2.  Credit  your  account Atomic • – If  we  group  both  steps  together – and  control  that  group  such  that  either both  steps  succeed  or • nothing  gets  changed • – then  we’ve  achieved  atomicityConsistent 10 My  Account Your  Account Two-­‐Step  Process 1.  Debit  my  account 2.  Credit  your  account Consistent:  results  are  valid • 1 – all  keys  and  constraints  remain  in-­‐tact – my  account  is  debited  the  same  a  mount  that  your   account  is  credited  -­‐  10Isolated 10 My  Account Your  Account Two-­‐Step  Process 1.  Debit  my  account 2.  Credit  your  account Isolated:  when  are  changes  visible? • – If  the  change  is  isolated  then  neither  of  the   changes  should  be  visible  through  another   connec4on  un4l  we  indicate  that  the  process  is   done  (commit).Durable 10 My  Account Your  Account Two-­‐Step  Process 1.  Debit  my  account 2.  Credit  your  account Durable:  changes  s4ck • – even  if  the  database  crashesTransactions ACID  is  a  set  of  proper4es  that  define  the   • reliability  of  a  set  of  changes  (to  a  database) –Atomic  -­‐  all  or  nothing –Consistent  -­‐  results  are  valid –Isolated  -­‐  indicates  when  changes  become  visible –Durable  -­‐  changes  s4ck  no  maLer  what The  Atomic  and  Isolated  proper)es  require  demarca)on   of  scope...  i.e.  the  boundaries  of  a  transac)onDemo Transac)on  in  Vanilla  JDBCSpring  Transac)on  ManagementSpring  Transaction  Management Spring  provides  a  consistent  abstrac4on  for   • transac4on  management – declara4ve  and  programa4c  methods – consistent  between  JDBC,  JPA/Hibernate  etc. – nicely  integrated  with  other  Spring  stuff – intui4ve  and  easy  to  useSpring  Transaction  Management Configura4on  in  the  Java  Stack • – Applica4onContext.xml stack-­‐db:transac)on-­‐manager  / • Configures  a  transac4on  manager  named  transac4onManager – JpaTransac)onManager  for  JPA » DataSourceTransac)onManager  otherwise » tx:annota)on-­‐driven  / • Configures  the  applica4on  to  use  Transac4onal  annota4ons   – to  demarcate  transac4on  boundaries  declara4velySpring  Transaction  Management Two  means  of  doing  transac4ons  in  Spring   • programma4cally – Pla\ormTransac4onManager not  covered  in  this  training • – Transac4onTemplate...Spring  Transaction  Management Transac4onTemplate • – callback  approach  similar  to  JdbcTemplate – handles  much  of  the  boilerplate  code – releases  transac4onal  resources – but  couples  your  code  to  Spring’s  transac4on   framework –per  Spring,  use  it  only  when  necessaryDemo Demo Spring  Transac4onTemplateSpring  Transaction  Management Spring  declara)ve  transac4on  management • – Simple – Non-­‐invasive – handles  much  of  the  boilerplate  code – releases  transac4onal  resources – Most  common  method – Recommended  method  (v.s.  programa4c)Spring  Transaction  Management Declara4ve  transac4ons  can  be  configured  via   • xml  or  annota4ons  -­‐  we’ll  cover  annota4ons Specify  transac4onal  behavior  on  a  per-­‐ • method  basis Spring  takes  care  of  the  the  rest  (using  AOP) •

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.