SlideShare a Scribd company logo
 
 
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
 
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; >   < bean id = &quot;dataSource” class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; >   < property  name = &quot;driverClassName&quot;  value = &quot;org.hsqldb.jdbcDriver&quot;  /> < property  name = &quot;url&quot;  value = &quot;jdbc:hsqldb:hsql://C:/db&quot;  /> < property  name = &quot;username&quot;  value = &quot;sa&quot;  /> < property  name = &quot;password&quot;  value = &quot;&quot;  /> </ bean > </ beans >
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; >   < bean id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; >   < property  name = &quot;driverClassName&quot;  value = &quot;org.hsqldb.jdbcDriver&quot;  /> < property  name = &quot;url”  value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot;  /> < property  name = &quot;username&quot;  value = &quot;sa&quot;  /> < property  name = &quot;password“ value = &quot;&quot;  />   </ bean > < bean id = &quot;jdbcTemplate&quot; class = &quot;org.springframework.jdbc.core.JdbcTemplate&quot; lazy-init = &quot;false&quot; > < property  name = &quot;dataSource&quot;  ref = &quot;dataSource&quot;  /> < property  name = &quot;lazyInit&quot;  value = &quot;false&quot;  />   </ bean >     </ beans >
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
<? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean  id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource”  lazy-init = &quot;false&quot; > < property  name = &quot;driverClassName&quot;  value = &quot;org.hsqldb.jdbcDriver&quot;  /> < property  name = &quot;url&quot;  value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot;  /> < property  name = &quot;username&quot;  value = &quot;sa&quot;  /> < property  name = &quot;password&quot;  value = &quot;&quot;  /> </ bean > < bean  id = &quot;sessionFactory&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot; lazy-init = &quot;false&quot; > < property  name = &quot;dataSource&quot;  ref = &quot;dataSource&quot;  /> < property  name = &quot;mappingResources&quot; > < list > < value > com/targettrust/spring/hibernate/Pessoa.hbm.xml </ value > </ list > </ property > < property  name = &quot;hibernateProperties&quot; > < props >   < prop  key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.PointbaseDialect </ prop >   < prop  key = &quot;hibernate.hbm2ddl.auto&quot; > create </ prop > </ props > </ property > </ bean > </ beans >
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
package  com.targettrust.spring.hibernate; public   class  Pessoa { private  Long  id ; private  String  nome ; private  String  email ; // Getters e Setters } <? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> <! DOCTYPE  hibernate-mapping  PUBLIC  &quot;-//Hibernate/Hibernate Mapping DTD//EN&quot;  &quot;http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd&quot; > < hibernate-mapping > < class  name = &quot;com.targettrust.spring.hibernate.Pessoa&quot;  table = &quot;pessoa&quot; > < id  name = &quot;id&quot;  column = &quot;id&quot;  type = &quot;java.lang.Long&quot;  unsaved-value = &quot;0&quot; > < generator  class = &quot;increment&quot; /> </ id > < property  name = &quot;nome&quot;  column = &quot;nome&quot;  type = &quot;java.lang.String&quot; /> < property  name = &quot;email&quot;  column = &quot;email&quot;  type = &quot;java.lang.String&quot; />   </ class > </ hibernate-mapping >
<? xml  version = &quot;1.0&quot;  encoding = &quot;UTF-8&quot; ?> < beans  xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean  id = &quot;dataSource” lazy-init = &quot;false” class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource“ > < property  name = &quot;driverClassName&quot;  value = &quot;org.hsqldb.jdbcDriver&quot;  /> < property  name = &quot;url&quot;  value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot;  /> < property  name = &quot;username&quot;  value = &quot;sa&quot;  /> < property  name = &quot;password&quot;  value = &quot;&quot;  /> </ bean > < bean  id = &quot;sessionFactory“  lazy-init = &quot;false&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean“ > < property  name = &quot;dataSource&quot;  ref = &quot;dataSource&quot;  /> < property  name = &quot;mappingResources&quot; > < list >< value > com/targettrust/spring/hibernate/Pessoa.hbm.xml </ value ></ list > </ property > < property  name = &quot;hibernateProperties&quot; > < props > < prop  key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.PointbaseDialect </ prop > </ props > </ property > </ bean > < bean  id = &quot;hibernateTemplate“  lazy-init = &quot;false” class = &quot;org.springframework.orm.hibernate3.HibernateTemplate“ > < property  name = &quot;sessionFactory&quot;  ref = &quot;sessionFactory&quot;  /> </ bean > </ beans >
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
<!-- Defini ç ão do Dataource para acesso ao banco HSQLDB --> < bean  id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; > < property  name = &quot;driverClassName&quot;  value = &quot;org.hsqldb.jdbcDriver&quot;  /> < property  name = &quot;url&quot;  value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot;  /> <property  name = &quot;username&quot;  value = &quot;sa&quot;  /> < property  name = &quot;password&quot;  value = &quot;&quot;  /> </ bean >
<!-- Defini ç ão da SessionFactory do Hibernate --> < bean  id = &quot;sessionFactory&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot; lazy-init = &quot;false&quot; > < property  name = &quot;dataSource&quot;  ref = &quot;dataSource&quot;  /> < property  name = &quot;mappingResources&quot; > < list > < value > com/targettrust/spring/transaction/Produto.hbm.xml </ value > </ list > </ property > < property  name = &quot;hibernateProperties&quot; > < props > < prop  key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.HSQLDialect </ prop > </ props > </ property ></ bean >
<!-- Defini ç ão do TransactionManager, nesse caso o escolhido para a tarefa de gerencia as   transa ç ões foi o org.springframework.orm.hibernate3.HibernateTransactionManager que   gerencia transa ç ões entre Hibernate e JDBC pelo DataSource --> < bean  id = &quot;txManager&quot;  class = &quot;org.springframework.orm.hibernate3.HibernateTransactionManager&quot; > < property  name = &quot;sessionFactory&quot;  ref = &quot;sessionFactory&quot; /> </ bean >
define os pontos do sistema   que seram interceptados, nesse caso  é  a execu ç ão de qaulquer metodos do ProdutoService.   Depois ele vincula essas classes interceptadas com um advice o txAdvice;   --> < aop:config > < aop:pointcut  id = &quot;produtoServiceMetodos&quot;  expression = &quot;execution(* com.targettrust.spring.transaction.ProdutoService.*(..))&quot;  /> < aop:advisor  advice-ref = &quot;txAdvice&quot;  pointcut-ref = &quot;produtoServiceMetodos&quot;  /> </ aop:config >
<!-- Defini ç ão do Advide AOP que casa o gerente de transa ç ões com os metodos Esse beans informa que metodos e como esses metodos devem ser tratados pela transa ç ão --> < tx:advice  id = &quot;txAdvice&quot;  transaction-manager = &quot;txManager&quot; > < tx:attributes > < tx:method  name = &quot;salvar*&quot;  propagation = &quot;REQUIRED&quot;  />   < tx:method  name = &quot;findAll&quot;  propagation = &quot;REQUIRED&quot;  read-only = &quot;true&quot; /> </ tx:attributes ></ tx:advice >
[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

Joomla Day Austin Part 3
Joomla Day Austin Part 3Joomla Day Austin Part 3
Joomla Day Austin Part 3
Kyle Ledbetter
 
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
irwinvifxcfesre
 
iBatis course (beta)
iBatis course (beta)iBatis course (beta)
iBatis course (beta)
Marcelo Honores
 
Creating a Resource Type with Apache Lenya 2.0
Creating a Resource Type with Apache Lenya 2.0Creating a Resource Type with Apache Lenya 2.0
Creating a Resource Type with Apache Lenya 2.0nobby
 
Css101
Css101Css101
Css101
Alipay
 
Chief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for KeefChief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for Keef
chicagonewsonlineradio
 
Curso Symfony - Clase 5
Curso Symfony - Clase 5Curso Symfony - Clase 5
Curso Symfony - Clase 5
Javier Eguiluz
 
Poetry in the age of hip-hop
Poetry in the age of hip-hopPoetry in the age of hip-hop
Poetry in the age of hip-hop
chicagonewsonlineradio
 
Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)
Marco Cedaro
 
Django, el framework web para perfeccionistas con deadlines
Django, el framework web para perfeccionistas con deadlinesDjango, el framework web para perfeccionistas con deadlines
Django, el framework web para perfeccionistas con deadlines
Leonardo Soto
 

What's hot (10)

Joomla Day Austin Part 3
Joomla Day Austin Part 3Joomla Day Austin Part 3
Joomla Day Austin Part 3
 
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
Peek inside the fantastical Ukrainian Village home and studio of artists Jare...
 
iBatis course (beta)
iBatis course (beta)iBatis course (beta)
iBatis course (beta)
 
Creating a Resource Type with Apache Lenya 2.0
Creating a Resource Type with Apache Lenya 2.0Creating a Resource Type with Apache Lenya 2.0
Creating a Resource Type with Apache Lenya 2.0
 
Css101
Css101Css101
Css101
 
Chief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for KeefChief Keef's hologram can't catch a break, and it's a win for Keef
Chief Keef's hologram can't catch a break, and it's a win for Keef
 
Curso Symfony - Clase 5
Curso Symfony - Clase 5Curso Symfony - Clase 5
Curso Symfony - Clase 5
 
Poetry in the age of hip-hop
Poetry in the age of hip-hopPoetry in the age of hip-hop
Poetry in the age of hip-hop
 
Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)Back To The Front - Javascript Test Driven Development is between us (workshop)
Back To The Front - Javascript Test Driven Development is between us (workshop)
 
Django, el framework web para perfeccionistas con deadlines
Django, el framework web para perfeccionistas con deadlinesDjango, el framework web para perfeccionistas con deadlines
Django, el framework web para perfeccionistas con deadlines
 

Viewers also liked

CENTR+
CENTR+CENTR+
Italian Conference on Nagios: Michael Medin on Windows Monitoring
Italian Conference on Nagios: Michael Medin on Windows MonitoringItalian Conference on Nagios: Michael Medin on Windows Monitoring
Italian Conference on Nagios: Michael Medin on Windows Monitoring
Würth Phoenix
 
Namasmaran Bestseller On Superliving Dr. Shriniwas Kashalikar
Namasmaran Bestseller On Superliving  Dr. Shriniwas KashalikarNamasmaran Bestseller On Superliving  Dr. Shriniwas Kashalikar
Namasmaran Bestseller On Superliving Dr. Shriniwas Kashalikarshivsr5
 
What Women Want?
What Women Want?What Women Want?
What Women Want?RedPrairie
 
20141223 kuznetsov distributed
20141223 kuznetsov distributed20141223 kuznetsov distributed
20141223 kuznetsov distributed
Computer Science Club
 
El Mundo En 100 Personas
El Mundo En 100 PersonasEl Mundo En 100 Personas
El Mundo En 100 PersonasFree- Dominius
 
Algebra
AlgebraAlgebra
Lesson 6 - Ethnicity
Lesson 6 - EthnicityLesson 6 - Ethnicity
Lesson 6 - Ethnicity
Elle Sullivan
 
Clonagem
ClonagemClonagem
Clonagem
Gustavo Gustavo
 
El Baile
El BaileEl Baile
El Baile
gabylozada
 
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
Tommy Darker
 
02 2016 Workshop VON
02 2016 Workshop VON02 2016 Workshop VON
02 2016 Workshop VON
femkebrand
 
William Penn
William PennWilliam Penn
William Penn
Chuck Thompson
 
Libre
LibreLibre
Metodos de encuadernación.
Metodos de encuadernación.Metodos de encuadernación.
Metodos de encuadernación.Nathaly Correa
 
Formations en pnl, coaching et hypnose certifiantes INLPTA
Formations en pnl, coaching  et hypnose certifiantes INLPTAFormations en pnl, coaching  et hypnose certifiantes INLPTA
Formations en pnl, coaching et hypnose certifiantes INLPTA
Kamal Benrahma
 

Viewers also liked (20)

CENTR+
CENTR+CENTR+
CENTR+
 
Italian Conference on Nagios: Michael Medin on Windows Monitoring
Italian Conference on Nagios: Michael Medin on Windows MonitoringItalian Conference on Nagios: Michael Medin on Windows Monitoring
Italian Conference on Nagios: Michael Medin on Windows Monitoring
 
Namasmaran Bestseller On Superliving Dr. Shriniwas Kashalikar
Namasmaran Bestseller On Superliving  Dr. Shriniwas KashalikarNamasmaran Bestseller On Superliving  Dr. Shriniwas Kashalikar
Namasmaran Bestseller On Superliving Dr. Shriniwas Kashalikar
 
What Women Want?
What Women Want?What Women Want?
What Women Want?
 
20141223 kuznetsov distributed
20141223 kuznetsov distributed20141223 kuznetsov distributed
20141223 kuznetsov distributed
 
екскурсія до м.києва
екскурсія до м.києваекскурсія до м.києва
екскурсія до м.києва
 
El Mundo En 100 Personas
El Mundo En 100 PersonasEl Mundo En 100 Personas
El Mundo En 100 Personas
 
Algebra
AlgebraAlgebra
Algebra
 
Lesson 6 - Ethnicity
Lesson 6 - EthnicityLesson 6 - Ethnicity
Lesson 6 - Ethnicity
 
Clonagem
ClonagemClonagem
Clonagem
 
El Baile
El BaileEl Baile
El Baile
 
на сайт
на сайтна сайт
на сайт
 
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
Tyrone Isaac-Stuart - How Musicpreneurs Deal With Their Struggles [Darker Mus...
 
Rakumo intro
Rakumo introRakumo intro
Rakumo intro
 
02 2016 Workshop VON
02 2016 Workshop VON02 2016 Workshop VON
02 2016 Workshop VON
 
William Penn
William PennWilliam Penn
William Penn
 
Un voyage chine-tibete
Un voyage chine-tibeteUn voyage chine-tibete
Un voyage chine-tibete
 
Libre
LibreLibre
Libre
 
Metodos de encuadernación.
Metodos de encuadernación.Metodos de encuadernación.
Metodos de encuadernación.
 
Formations en pnl, coaching et hypnose certifiantes INLPTA
Formations en pnl, coaching  et hypnose certifiantes INLPTAFormations en pnl, coaching  et hypnose certifiantes INLPTA
Formations en pnl, coaching et hypnose certifiantes INLPTA
 

More from Diego Pacheco

Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!
Diego Pacheco
 
Continuous Discovery Habits Book Review.pdf
Continuous Discovery Habits  Book Review.pdfContinuous Discovery Habits  Book Review.pdf
Continuous Discovery Habits Book Review.pdf
Diego Pacheco
 
Thoughts about Shape Up
Thoughts about Shape UpThoughts about Shape Up
Thoughts about Shape Up
Diego Pacheco
 
Holacracy
HolacracyHolacracy
Holacracy
Diego Pacheco
 
AWS IAM
AWS IAMAWS IAM
AWS IAM
Diego Pacheco
 
Encryption Deep Dive
Encryption Deep DiveEncryption Deep Dive
Encryption Deep Dive
Diego Pacheco
 
Sec 101
Sec 101Sec 101
Sec 101
Diego Pacheco
 
Reflections on SCM
Reflections on SCMReflections on SCM
Reflections on SCM
Diego Pacheco
 
Management: Doing the non-obvious! III
Management: Doing the non-obvious! IIIManagement: Doing the non-obvious! III
Management: Doing the non-obvious! III
Diego Pacheco
 
Design is not Subjective
Design is not SubjectiveDesign is not Subjective
Design is not Subjective
Diego Pacheco
 
Architecture & Engineering : Doing the non-obvious!
Architecture & Engineering :  Doing the non-obvious!Architecture & Engineering :  Doing the non-obvious!
Architecture & Engineering : Doing the non-obvious!
Diego Pacheco
 
Management doing the non-obvious II
Management doing the non-obvious II Management doing the non-obvious II
Management doing the non-obvious II
Diego Pacheco
 
Testing in production
Testing in productionTesting in production
Testing in production
Diego Pacheco
 
Nine lies about work
Nine lies about workNine lies about work
Nine lies about work
Diego Pacheco
 
Management: doing the nonobvious!
Management: doing the nonobvious!Management: doing the nonobvious!
Management: doing the nonobvious!
Diego Pacheco
 
AI and the Future
AI and the FutureAI and the Future
AI and the Future
Diego Pacheco
 
Dealing with dependencies
Dealing  with dependenciesDealing  with dependencies
Dealing with dependencies
Diego Pacheco
 
Dealing with dependencies in tests
Dealing  with dependencies in testsDealing  with dependencies in tests
Dealing with dependencies in tests
Diego Pacheco
 
Kanban 2020
Kanban 2020Kanban 2020
Kanban 2020
Diego Pacheco
 

More from Diego Pacheco (20)

Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!Naming Things Book : Simple Book Review!
Naming Things Book : Simple Book Review!
 
Continuous Discovery Habits Book Review.pdf
Continuous Discovery Habits  Book Review.pdfContinuous Discovery Habits  Book Review.pdf
Continuous Discovery Habits Book Review.pdf
 
Thoughts about Shape Up
Thoughts about Shape UpThoughts about Shape Up
Thoughts about Shape Up
 
Holacracy
HolacracyHolacracy
Holacracy
 
AWS IAM
AWS IAMAWS IAM
AWS IAM
 
CDKs
CDKsCDKs
CDKs
 
Encryption Deep Dive
Encryption Deep DiveEncryption Deep Dive
Encryption Deep Dive
 
Sec 101
Sec 101Sec 101
Sec 101
 
Reflections on SCM
Reflections on SCMReflections on SCM
Reflections on SCM
 
Management: Doing the non-obvious! III
Management: Doing the non-obvious! IIIManagement: Doing the non-obvious! III
Management: Doing the non-obvious! III
 
Design is not Subjective
Design is not SubjectiveDesign is not Subjective
Design is not Subjective
 
Architecture & Engineering : Doing the non-obvious!
Architecture & Engineering :  Doing the non-obvious!Architecture & Engineering :  Doing the non-obvious!
Architecture & Engineering : Doing the non-obvious!
 
Management doing the non-obvious II
Management doing the non-obvious II Management doing the non-obvious II
Management doing the non-obvious II
 
Testing in production
Testing in productionTesting in production
Testing in production
 
Nine lies about work
Nine lies about workNine lies about work
Nine lies about work
 
Management: doing the nonobvious!
Management: doing the nonobvious!Management: doing the nonobvious!
Management: doing the nonobvious!
 
AI and the Future
AI and the FutureAI and the Future
AI and the Future
 
Dealing with dependencies
Dealing  with dependenciesDealing  with dependencies
Dealing with dependencies
 
Dealing with dependencies in tests
Dealing  with dependencies in testsDealing  with dependencies in tests
Dealing with dependencies in tests
 
Kanban 2020
Kanban 2020Kanban 2020
Kanban 2020
 

Spring Capitulo 04

  • 1.  
  • 2.  
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.  
  • 8.
  • 9. <? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean id = &quot;dataSource” class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; > < property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> < property name = &quot;url&quot; value = &quot;jdbc:hsqldb:hsql://C:/db&quot; /> < property name = &quot;username&quot; value = &quot;sa&quot; /> < property name = &quot;password&quot; value = &quot;&quot; /> </ bean > </ beans >
  • 10.
  • 11. <? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; > < property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> < property name = &quot;url” value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot; /> < property name = &quot;username&quot; value = &quot;sa&quot; /> < property name = &quot;password“ value = &quot;&quot; /> </ bean > < bean id = &quot;jdbcTemplate&quot; class = &quot;org.springframework.jdbc.core.JdbcTemplate&quot; lazy-init = &quot;false&quot; > < property name = &quot;dataSource&quot; ref = &quot;dataSource&quot; /> < property name = &quot;lazyInit&quot; value = &quot;false&quot; /> </ bean > </ beans >
  • 12.
  • 13.
  • 14. <? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource” lazy-init = &quot;false&quot; > < property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> < property name = &quot;url&quot; value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot; /> < property name = &quot;username&quot; value = &quot;sa&quot; /> < property name = &quot;password&quot; value = &quot;&quot; /> </ bean > < bean id = &quot;sessionFactory&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot; lazy-init = &quot;false&quot; > < property name = &quot;dataSource&quot; ref = &quot;dataSource&quot; /> < property name = &quot;mappingResources&quot; > < list > < value > com/targettrust/spring/hibernate/Pessoa.hbm.xml </ value > </ list > </ property > < property name = &quot;hibernateProperties&quot; > < props > < prop key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.PointbaseDialect </ prop > < prop key = &quot;hibernate.hbm2ddl.auto&quot; > create </ prop > </ props > </ property > </ bean > </ beans >
  • 15.
  • 16.
  • 17.
  • 18. package com.targettrust.spring.hibernate; public class Pessoa { private Long id ; private String nome ; private String email ; // Getters e Setters } <? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> <! DOCTYPE hibernate-mapping PUBLIC &quot;-//Hibernate/Hibernate Mapping DTD//EN&quot; &quot;http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd&quot; > < hibernate-mapping > < class name = &quot;com.targettrust.spring.hibernate.Pessoa&quot; table = &quot;pessoa&quot; > < id name = &quot;id&quot; column = &quot;id&quot; type = &quot;java.lang.Long&quot; unsaved-value = &quot;0&quot; > < generator class = &quot;increment&quot; /> </ id > < property name = &quot;nome&quot; column = &quot;nome&quot; type = &quot;java.lang.String&quot; /> < property name = &quot;email&quot; column = &quot;email&quot; type = &quot;java.lang.String&quot; /> </ class > </ hibernate-mapping >
  • 19. <? xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot; ?> < beans xmlns = &quot;http://www.springframework.org/schema/beans&quot; xmlns:xsi = &quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation = &quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&quot; > < bean id = &quot;dataSource” lazy-init = &quot;false” class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource“ > < property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> < property name = &quot;url&quot; value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot; /> < property name = &quot;username&quot; value = &quot;sa&quot; /> < property name = &quot;password&quot; value = &quot;&quot; /> </ bean > < bean id = &quot;sessionFactory“ lazy-init = &quot;false&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean“ > < property name = &quot;dataSource&quot; ref = &quot;dataSource&quot; /> < property name = &quot;mappingResources&quot; > < list >< value > com/targettrust/spring/hibernate/Pessoa.hbm.xml </ value ></ list > </ property > < property name = &quot;hibernateProperties&quot; > < props > < prop key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.PointbaseDialect </ prop > </ props > </ property > </ bean > < bean id = &quot;hibernateTemplate“ lazy-init = &quot;false” class = &quot;org.springframework.orm.hibernate3.HibernateTemplate“ > < property name = &quot;sessionFactory&quot; ref = &quot;sessionFactory&quot; /> </ bean > </ beans >
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. <!-- Defini ç ão do Dataource para acesso ao banco HSQLDB --> < bean id = &quot;dataSource&quot; class = &quot;org.springframework.jdbc.datasource.DriverManagerDataSource&quot; lazy-init = &quot;false&quot; > < property name = &quot;driverClassName&quot; value = &quot;org.hsqldb.jdbcDriver&quot; /> < property name = &quot;url&quot; value = &quot;jdbc:hsqldb:file:///C:targetspringdb&quot; /> <property name = &quot;username&quot; value = &quot;sa&quot; /> < property name = &quot;password&quot; value = &quot;&quot; /> </ bean >
  • 25. <!-- Defini ç ão da SessionFactory do Hibernate --> < bean id = &quot;sessionFactory&quot; class = &quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot; lazy-init = &quot;false&quot; > < property name = &quot;dataSource&quot; ref = &quot;dataSource&quot; /> < property name = &quot;mappingResources&quot; > < list > < value > com/targettrust/spring/transaction/Produto.hbm.xml </ value > </ list > </ property > < property name = &quot;hibernateProperties&quot; > < props > < prop key = &quot;hibernate.dialect&quot; > org.hibernate.dialect.HSQLDialect </ prop > </ props > </ property ></ bean >
  • 26. <!-- Defini ç ão do TransactionManager, nesse caso o escolhido para a tarefa de gerencia as transa ç ões foi o org.springframework.orm.hibernate3.HibernateTransactionManager que gerencia transa ç ões entre Hibernate e JDBC pelo DataSource --> < bean id = &quot;txManager&quot; class = &quot;org.springframework.orm.hibernate3.HibernateTransactionManager&quot; > < property name = &quot;sessionFactory&quot; ref = &quot;sessionFactory&quot; /> </ bean >
  • 27. define os pontos do sistema que seram interceptados, nesse caso é a execu ç ão de qaulquer metodos do ProdutoService. Depois ele vincula essas classes interceptadas com um advice o txAdvice; --> < aop:config > < aop:pointcut id = &quot;produtoServiceMetodos&quot; expression = &quot;execution(* com.targettrust.spring.transaction.ProdutoService.*(..))&quot; /> < aop:advisor advice-ref = &quot;txAdvice&quot; pointcut-ref = &quot;produtoServiceMetodos&quot; /> </ aop:config >
  • 28. <!-- Defini ç ão do Advide AOP que casa o gerente de transa ç ões com os metodos Esse beans informa que metodos e como esses metodos devem ser tratados pela transa ç ão --> < tx:advice id = &quot;txAdvice&quot; transaction-manager = &quot;txManager&quot; > < tx:attributes > < tx:method name = &quot;salvar*&quot; propagation = &quot;REQUIRED&quot; /> < tx:method name = &quot;findAll&quot; propagation = &quot;REQUIRED&quot; read-only = &quot;true&quot; /> </ tx:attributes ></ tx:advice >
  • 29.