User Tools

Site Tools


at-m42:lecture14

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
at-m42:lecture14 [2009/04/26 10:10] eechrisat-m42:lecture14 [2011/01/14 12:45] (current) – external edit 127.0.0.1
Line 462: Line 462:
   * If you have a pool of connections you'd want to release your connection (returning it to the pool) when you've finished.   * If you have a pool of connections you'd want to release your connection (returning it to the pool) when you've finished.
      
-=====Simplified Queries with Groovy =====+=====  Simplified Queries with Groovy ===== 
 + 
  
 <code groovy 1|Example 2; Database lookup in Groovy (at-m42/Lectures/lecture14/Lookup.groovy)> <code groovy 1|Example 2; Database lookup in Groovy (at-m42/Lectures/lecture14/Lookup.groovy)>
Line 562: Line 563:
 ===== Persistence Patterns: Transaction script ===== ===== Persistence Patterns: Transaction script =====
 In many applications it is natural to work directly with the relational model, issuing SQL queries and parsing result sets. In many applications it is natural to work directly with the relational model, issuing SQL queries and parsing result sets.
-  * This is known as the //[[http://martinfowler.com/eaaCatalog/transactionScript.html|Transaction Script]]// pattern((All patterns discussed in this lecture are from Fowler, //Patterns of Enterprise Application Architecture//.)): business logic is organized into procedures for each use case.+  * This is known as the //[[http://martinfowler.com/eaaCatalog/transactionScript.html|Transaction Script]]// pattern((All patterns discussed in this lecture are from //Patterns of Enterprise Application Architecture//. See [[Recommended Reading]] for bibliographic details.)): business logic is organized into procedures for each use case.
   * Direct use of SQL is also well suited for aggregating queries and set-based updates (accessing large amounts of data or updating many tables in the same transaction)   * Direct use of SQL is also well suited for aggregating queries and set-based updates (accessing large amounts of data or updating many tables in the same transaction)
 +
 ===== Persistence Patterns: ORM ===== ===== Persistence Patterns: ORM =====
  
Line 629: Line 631:
      
  
- 
- 
-===== Some Issues that the Developers of an ORM Have to be Aware Of ===== 
-  * //Identity//: ensuring a record in a database is unique in a global sense. 
-  * //Instantiated objects should be cached//: avoids a further trip to the database if it is needed in two separate transactions. 
-  * "Dirty" objects (objects that have been created or changed in a transaction) //have to be committed to the database in a single atomic operation//. 
-  * Objects that have not been changed do not need to be written back to the database. 
-  * Queries may result in large numbers of records being returned from a database: 
-    * Usually returned as a collection 
-    * However objects in the collection should not be instantiated unless it is needed. 
-===== Choosing a Persistence Strategy (1) ===== 
-  * Many enterprise applications need to use legacy databases, or share the database with other systems, so choices are limited! 
-  * Despite the hype, it is rare for an enterprise to change its database supplier, so it is often not worth completely abstracting the details of a DBMS out of code. 
-  * It is worth providing a data access layer so that your business logic does not talk directly JDBC but goes through a set of //Data Access Objects// 
-    * If the database schema changes, it will be in the access layer that changes will be needed, not in the business logic. 
-    * If the business logic changes, again, persistence code changes are limited to the access layer. 
-===== Choosing a Persistence Strategy (2) ===== 
-  * In some applications with a limited number of simple tables it will be quickest to use //active record// and talk directly to the database. 
-  * If the application will require heavy use of set access, aggregation of data from many tables, or batch updates in many rows, a direct implementation using //transaction script// may be most efficient. 
-  * ORM is a complex strategy which be of benefit only for complex domain models and or databases 
-===== Choosing a Persistence Strategy (3) ===== 
-ORM can be of benefit if: 
-  * Your application has the typical CRUD – create, retrieve, update, delete – workflow for domain objects. 
-  * Objects are found in large sets but are updated and deleted individually. 
-  * A large number of objects exist but they are "read-mostly" 
-  * There is a natural mapping between classes and fields and database tables and records 
-  * There are no unusual requirements such as the need to use customized SQL optimizations. 
-  * For Java programmers ORM has the advantage of keeping SQL out of the code. But that is why we have DB architects! 
-   
  
 ===== Lecture Contents ===== ===== Lecture Contents =====
  
-  * **[[#What is a Relational Database?|An introduction to relational databases and SQL]]**+  * [[#What is a Relational Database?|An introduction to relational databases and SQL]]
   * [[#The Trouble with Databases|JDBC -- Java database connectivity API]]   * [[#The Trouble with Databases|JDBC -- Java database connectivity API]]
-  * [[Immortal Objects]] +  * [[#Immortal Objects]] 
-  * [[Persistence Patterns]] +  * [[#Persistence Patterns]] 
-  * [[Other forms of Enterprise Integration]]+  * **[[#Other forms of Enterprise Integration]]**
      
 ===== Other Forms of Enterprise Integration ===== ===== Other Forms of Enterprise Integration =====
  
   * Enterprise integration is not just about databases and SQL.   * Enterprise integration is not just about databases and SQL.
-  * Enterprise information systems such as:+  * Enterprise information systms also often have to be built in to enterprise applications. 
 +  * Main technologies for this form of integration is the Java Connectivity API and Web Services. 
 +  * May not be talking Java so CORBA and similar technologies may come into play. 
 +   
 +---- 
 + 
 +Some examples of enterprise information systems are: 
   * Human Resources Systems   * Human Resources Systems
   * Payroll systems   * Payroll systems
Line 676: Line 656:
   * Business to Business Systems   * Business to Business Systems
   * Enterprise communication systems   * Enterprise communication systems
-  * Other "legacy” systems  +  * Other //so-called// "legacysystems  
-  * also often have to be built in to enterprise applications. +  
-  * Main technologies are the Java Connectivity API and Web Services. +
-  * May not be talking Java so CORBA and similar technologies come into play.+
 ===== Lecture Summary ===== ===== Lecture Summary =====
  
   * [[#What is a Relational Database?|An introduction to relational databases and SQL]]   * [[#What is a Relational Database?|An introduction to relational databases and SQL]]
   * [[#The Trouble with Databases|JDBC -- Java database connectivity API]]   * [[#The Trouble with Databases|JDBC -- Java database connectivity API]]
-  * [[Immortal Objects]] +  * [[#Immortal Objects]] 
-  * [[Persistence Patterns]] +  * [[#Persistence Patterns]] 
-  * [[Other forms of Enterprise Integration]]+  * [[#Other forms of Enterprise Integration]]
  
 ---- ----
  
 [[Home]] | [[lecture13|Previous Lecture]] | [[Lectures]] | [[lecture15|Next Lecture]]  [[Home]] | [[lecture13|Previous Lecture]] | [[Lectures]] | [[lecture15|Next Lecture]] 
at-m42/lecture14.1240740642.txt.gz · Last modified: 2011/01/14 12:24 (external edit)