Transfer 101 Dan Vega
2www.cfunited.com About Me Programmer ColdFusion / Flex / AS3 / HTML / JS / CSS / Groovy & Grails Cleveland ColdFusion User Group Co Manager Active ColdFusion Community Member (Love Teaching) Open Source Developer CFMU (ColdFusion Multi Uploader) RocketFM (ColdFusion + Flex File Manager) cfPayflowPro (Payflow Pro API for ColdFusion) cfPanel creator along with Todd Sharp Cleveland OH / Sports Fan / Running / Weight Lifting / Poker STERIS – Web Developer ( Blogger –
3www.cfunited.com Transfer 101 Agenda What is an ORM and why does it exist What is Transfer Installing Transfer CRUD e-commerce application demo Relationships Decorators Q&A – Feel free to ask questions whenever
4www.cfunited.com What Problems does an ORM solve When creating systems that are comprised of objects there are many repetitive tasks that have to be done on a per object basis Value Objects (beans) getters / setters Writing CRUD (Create/Read/Update/Delete) Handling Relationships Populating objects with database queries Populating SQL with data from your objects
5www.cfunited.com What is Transfer An ORM (Object Relational Mapping) Library for ColdFusion Transfer ORM's main focus is to automate the repetitive tasks of creating the SQL and custom CFCs that are often required when developing a ColdFusion application. Through a central configuration file Transfer knows how to generate objects, and how to manage them and their relationships back to the database Created by Mark Mandel
6www.cfunited.com What it is not Hibernate / ColdFusion 9 ORM The end of SQL A code generator ORM Frameworks Reactor CFWheels
7www.cfunited.com Supported Systems CFML Engines Adobe ColdFusion MX 7+ Railo 3.0+ OpenBD 1.0+ ? Database Servers (What no Access?) MS SQL Server MySQL 4.1+ PostGres 8.1+ Oracle 9i+
8www.cfunited.com Installing Transfer Download the zip Setup a mapping Per application mappings in ColdFusion 8 rock! Drop it in your web root Configuration Datasource.xml / Transfer.xml / definitions Create Transfer factory & Transfer Instance
9www.cfunited.com Installation Demo
10www.cfunited.com CRUD - Create transfer.new(“object”) Returns a transfer.com.transferObject getters / setters for properties meta methods Object helper methods Events debug getPropertyMemento() (struct) demo
11www.cfunited.com CRUD - Save transfer.save(object) Update existing Create new demo
12www.cfunited.com CRUD - Read transfer.get(“object”,id) transfer.readByProperty(“object”,prop,val) transfer.readByPropertyMap(“object’,map) transfer.readByQuery(“object”,query)
13www.cfunited.com CRUD - Delete transfer.delete(object) transfer.cascadeDelete(object) demo
14www.cfunited.com Retrieving Query Lists Transfer.list(class, [orderProperty], [orderASC], [useAliases]) Transfer.listByProperty(class, property, value, [orderProperty], [orderASC], [useAliases]) Transfer.listByPropertyMap(class, propertyMap, [orderProperty], [orderASC], [useAliases]) Transfer.listByQuery(query)
15www.cfunited.com Demo
16www.cfunited.com Managing Relationships & Compositions Relationship types One to many Many to One Many to Many Collections Struct Array
17www.cfunited.com Demo
18www.cfunited.com Transfer Decorators A decorator is used when you wish to write your own CFC to be used to represent data, in place of the Transfer generated Object. Wraps and extends the transfer object Must extend transfer.com.TransferDecorator Decorator attribute on the object element in the transfer.xml configuration
19www.cfunited.com Demo
20www.cfunited.com Transfer 201 Decorators Cache Object Proxies Events Transfer & Flex Validation ValidateThis - Frameworks based on transfer Metro -
21www.cfunited.com ResourcesResources – Blog – Twitter
22www.cfunited.com Q&AQ&A