Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Relational Mapping Overview Presented By: Denard Springle Northern Virginia ColdFusion Users Group.

Similar presentations


Presentation on theme: "Object Relational Mapping Overview Presented By: Denard Springle Northern Virginia ColdFusion Users Group."— Presentation transcript:

1 Object Relational Mapping Overview Presented By: Denard Springle Northern Virginia ColdFusion Users Group

2  Database Vendor Independence  Caching & Concurrency  Performance Optimization  Faster Application Development  Reduces or Eliminates Database Design Cycles  Inherent Object Oriented Programming Application Development Framework

3 DAO  SQL Statements ,,  Tables as Bean CFCs  CRUD (Create, Retrieve, Update, Delete) written for each object as DAO  Complex DAO relationships  Increasingly complex code management ORM  Persistent CFCs  Inherent Getters & Setters  Inherent Object Relational Mapping  Automates database design  Automates relationships  Reduces Code  Reduces Complexity

4  Minimum required Application.cfc parameters for an ORM enabled application.  Defines additional settings that can be used to configure ORM.

5  customer.cfc   One should be created for each column in the table  To specify a column mapping use column=“ ” in the tag, otherwise the name is used as the column name

6  Retrieves all records from the customer table.  Creates new record and saves it to the customer table.  Loads a record, sets a new age and saves it back to customer table.  Deletes the record from the customer table

7  book.cfc 

8  customer.cfc   This defines a one-to-many relationship between a customer (one) and their books (many)

9  customer.cfc 

10  Retrieves an array of all customer objects  Retrieves a customer object whose primary key value is 27.  Retrieves an array of customer objects whose age is 35.  Retrieves an array of customer objects whose age is 35 sorted by name in descending order.  Retrieves a customer object for the customer whose name is ‘Jane Gum’.

11 INSERT  INSERT INTO customer ( name, age, email ) VALUES (,, ORM   oEx = EntityNew(“customer”); oEx.setName(“Jane Gum”); oEx.setAge(“35”); oEx.setemail(“nospam@nospam.com”); EntitySave(oEx); ormflush();

12 SELECT  SELECT * FROM customer  SELECT * FROM customer WHERE name = ‘Jane Gum’ ORM 

13 UPDATE  UPDATE customer SET age = 45 WHERE id = #qGetCustomer.id# ORM 

14 DELETE  DELETE FROM customer WHERE id = #qGetCustomer.id# ORM 

15 Output  #qGetCustomer.name# #qGetCustomer.age# #qGetCustomer.email#   #qGetCustomer.name# #qGetCustomer.age# #qGetCustomer.email#  UPDATE customer SET age = #qGetCustomer.age# WHERE id = #qGetCustomer.id# ORM Output  #oCustomer.getname()# #oCustomer.getage()# #oCustomer.getemail()#   #oCustomer.getname()# #oCustomer.getage()# #oCustomer.getemail()# 

16  Loads the customer object array and converts it to a query object.  Loads the customer object array and converts only the ‘email’ column to a query object.

17   Built-in functions to obtain data such as getage() and getname() cannot be used if you are using select queries with specific column names. The result will be returned as an array object and values can be retrieved using an array index.

18  Chapter 8: Coldfusion ORM in the ‘Developing ColdFusion 9 Applications’ reference.  Adobe’s tutorials (available from the CF9 product page)  Ben Forta’s, Ray Camden’s, Dan Wilson’s, Ben Nadel’s (and others) blogs are always excellent references for all things ColdFusion  NVCFUG Adobe Groups Website


Download ppt "Object Relational Mapping Overview Presented By: Denard Springle Northern Virginia ColdFusion Users Group."

Similar presentations


Ads by Google