3. Java Persistence API. 5. Transaction Management презентация
Содержание
- 2. Database Transaction A database transaction is a sequence of actions that
- 3. ACID (1 of 2) Atomicity. A transaction should be treated as
- 4. ACID (2 of 2) Isolation. There may be many transactions processing
- 5. Spring Transaction Management Spring framework provides an abstract layer on top
- 6. Local Transactions Local transaction management can be useful in a centralized
- 7. Global Transactions Global transaction management is required in a distributed computing
- 8. Programmatic vs. Declarative Spring supports two types of transaction management: Programmatic
- 9. Programmatic vs. Declarative Declarative transaction management is preferable over programmatic transaction
- 10. Spring Transaction Abstractions The key to the Spring transaction abstraction is
- 11. PlatformTransactionManager getTransaction - returns a currently active transaction or create a
- 12. TransactionDefinition Is the core interface of the transaction support in Spring
- 13. TransactionDefinition Methods getPropagationBehavior - returns the propagation behavior getIsolationLevel - returns
- 14. Isolation Level (1 of 2) TransactionDefinition.ISOLATION_DEFAULT - the default isolation level
- 15. Isolation Level (2 of 2) TransactionDefinition.ISOLATION_REPEATABLE_READ - dirty reads and non-repeatable
- 16. Propagation Types (1 of 2) TransactionDefinition.PROPAGATION_MANDATORY - support a current transaction;
- 17. Propagation Types (2 of 2) TransactionDefinition.PROPAGATION_REQUIRED - support a current transaction;
- 18. TransactionStatus interface Provides a simple way for transactional code to control
- 19. TransactionStatus Methods hasSavepoint - returns whether this transaction internally carries a
- 20. Declarative Transaction Management This approach allows you to manage the transaction
- 21. Configuring Transaction Management <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property
- 22. Using @Transactional You can place the @Transactional annotation before a class definition,
- 23. @Transactional Attributes propagation (Propagation.REQUIRED by default) Isolation (Isolation.DEFAULT by default) timeout
- 24. Exercise: Insert New Customer Insert new record to the CUSTOMER DB
- 25. New Save Interface Method package com.bionic.edu; public interface CustomerDao {
- 26. Save DAO Implementation @Repository public class CustomerDaoImpl implements CustomerDao{ @PersistenceContext
- 27. Save Service Implementation @Named public class CustomerServiceImpl implements CustomerService{ @Inject
- 28. Example: Payment of a New Customer The task is to add
- 29. PaymentDaoImpl Class package com.bionic.edu; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; import org.springframework.stereotype.Repository; @Repository
- 30. CustomerServiceImpl Class @Transactional public void add(Customer c, Payment p){
- 31. Output INSERT on table 'PAYMENT' caused a violation of foreign key
- 32. CustomerServiceImpl Class package com.bionic.edu; import javax.inject.Inject; import javax.inject.Named; import org.springframework.transaction.annotation.Transactional; @Named
- 33. PaymentServiceImpl Class @Named public class PaymentServiceImpl implements PaymentService{ @Inject
- 34. Output INSERT on table 'PAYMENT' caused a violation of foreign key
- 35. CustomerServiceImpl Class package com.bionic.edu; import javax.inject.Inject; import javax.inject.Named; import org.springframework.transaction.annotation.Transactional; @Named
- 36. Output JpaDialect does not support savepoints - check your JPA provider's
- 37. CustomerServiceImpl Class package com.bionic.edu; import javax.inject.Inject; import javax.inject.Named; import org.springframework.transaction.annotation.Transactional; @Named
- 38. Output Customer and Payment entities are successfully saved The problem
- 39. Payment Entity @Entity public class Payment { @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
- 40. Customer Entity @Entity public class Customer { @Id @GeneratedValue(strategy=GenerationType.IDENTITY)
- 41. Main Class Customer c = new Customer(); . . . .
- 42. Output Customer and Payment entities are successfully saved The problem
- 43. Скачать презентацию









































Слайды и текст этой презентации
Скачать презентацию на тему 3. Java Persistence API. 5. Transaction Management можно ниже:
Похожие презентации