Database-driven mobile   AIR applications     The power of ORM
Who Am I?Steven PeetersInstructor / consultant at multimediacollegeTM• Adobe Flex, AIR, Flash Catalyst & ColdFusion Certif...
Topics• Database in AIR• Using ColdFusion’s ORM• Synchronising with a remote server• Applying to mobile applicationsTwitte...
Database in AIR
Database in AIR• SQLite
Database in AIR• SQLite • Lightweight database
Database in AIR• SQLite • Lightweight database • Limited type support
Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use
Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use • Available offline
Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use • Available offline • Synchronous AND a...
Database encryption
Database encryption• 256-bit AES encryption
Database encryption• 256-bit AES encryption• Use EncryptionKeyGenerator to validate strength  of encryption key     • as3c...
Database encryption• 256-bit AES encryption• Use EncryptionKeyGenerator to validate strength  of encryption key      • as3...
Using ColdFusion’s ORM
Using ColdFusion’s ORM• Server-side technology on client-side?     • cfair.swc     • <server root>/CFIDE/Scripts/AIR
Using ColdFusion’s ORM• Server-side technology on client-side?     • cfair.swc     • <server root>/CFIDE/Scripts/AIR• Work...
Using ColdFusion’s ORM• Server-side technology on client-side?     • cfair.swc     • <server root>/CFIDE/Scripts/AIR• Work...
Using ColdFusion’s ORM• Server-side technology on client-side?     • cfair.swc     • <server root>/CFIDE/Scripts/AIR• Work...
Using ColdFusion’s ORM• Server-side technology on client-side?     • cfair.swc     • <server root>/CFIDE/Scripts/AIR• Work...
Entity Metadata
Entity Metadata• [Entity]
Entity Metadata• [Entity]• [Table(name=”<name>”)]
Entity Metadata• [Entity]• [Table(name=”<name>”)]• [RemoteClass(alias=”<cfc>”)]
Entity Metadata• [Entity]• [Table(name=”<name>”)]• [RemoteClass(alias=”<cfc>”)]• [Bindable]
Field Metadata
Field Metadata• [Id]
Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”,  initialValue=”1”, incrementBy=”1”)]
Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”,  initialValue=”1”, incrementBy=”1”)]• [Transient]
Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”,  initialValue=”1”, incrementBy=”1”)]• [Transient]• [Column(nam...
Relationship Metadata
Relationship Metadata
Relationship Metadata• [OneToOne(targetEntity=”<entity>”,  fetchType=”EAGER(default)|LAZY”)]
Relationship Metadata• [OneToOne(targetEntity=”<entity>”,  fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<en...
Relationship Metadata• [OneToOne(targetEntity=”<entity>”,  fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<en...
Relationship Metadata• [OneToOne(targetEntity=”<entity>”,  fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<en...
Relationship Metadata
Relationship Metadata• [JoinTable(name=”<name>”)]
Relationship Metadata• [JoinTable(name=”<name>”)]• [JoinColumn(name=”<name>”,  referencedColumnName=”<name>”)]
Relationship Metadata• [JoinTable(name=”<name>”)]• [JoinColumn(name=”<name>”,  referencedColumnName=”<name>”)]• [InverseJo...
Synchronising with remote server
Synchronising with remote server• Always asynchronous
Synchronising with remote server• Always asynchronous• Using SyncManager class   • port   • server   • syncCFC   • session
Synchronising with remote server
Synchronising with remote server• Fetching remote data   • syncManager.fetch(“foo”)
Synchronising with remote server• Fetching remote data   • syncManager.fetch(“foo”)• Save remote data in local SQLite data...
Synchronising with remote server
Synchronising with remote server• Reading data from local database
Synchronising with remote server• Reading data from local database   • session.load(<valueObject>, <filterObject>)
Synchronising with remote server• Reading data from local database   • session.load(<valueObject>, <filterObject>)   • sess...
Synchronising with remote server• Reading data from local database   • session.load(<valueObject>, <filterObject>)   • sess...
Synchronising with remote server• Reading data from local database   • session.load(<valueObject>, <filterObject>)   • sess...
Synchronising with remote server
Synchronising with remote server• Saving data to the local database
Synchronising with remote server• Saving data to the local database   • session.saveUpdate(<valueObject>)
Synchronising with remote server• Saving data to the local database   • session.saveUpdate(<valueObject>)   • session.dele...
Synchronising with remote server
Synchronising with remote server• Pushing data to the remote database
Synchronising with remote server• Pushing data to the remote database   • syncManager.autocommit = true
Synchronising with remote server• Pushing data to the remote database   • syncManager.autocommit = true   • session.commit()
What can you do with it?• Online/offline synchronisation• Use DB as (temporary) storage• Protect private data (encryption)•...
What can you do with it?
ORM on mobile devices
How hard is it?
ORM on mobile devices
ORM on mobile devices• What’s available?
ORM on mobile devices• What’s available?   • SQLite database
ORM on mobile devices• What’s available?   • SQLite database   • Disk access
ORM on mobile devices• What’s available?   • SQLite database   • Disk access   • Data contract?
ORM on mobile devices• What’s available?   • SQLite database   • Disk access   • Data contract?   • WiFi?
ORM on mobile devices
ORM on mobile devices• What’s different?
ORM on mobile devices• What’s different?   • AIR 2.5 minimum
ORM on mobile devices• What’s different?   • AIR 2.5 minimum   • Specify access rights in app.xml
ORM on mobile devices• What’s different?   • AIR 2.5 minimum   • Specify access rights in app.xml   • not much really...
So how hard is it then?          “It’s like stealing candy          from a baby!”
What can you do with it?
Thank you     Twitter:     @aikisteve     Email:     steven@multimediacollege.be     Personal site:     www.flexpert.be   ...
Upcoming SlideShare
Loading in …5
×

Scotch On The Rocks 2011

785 views

Published on

As of ColdFusion 9 you have the ability to create database driven applications by writing virtually no SQL statements using ORM. You can use this server-side feature on the client-side in an AIR application.

This session will talk you through the basics of using ColdFusion ORM in AIR and how to "automagically" synchronise your local data with a remote ColdFusion 9 server. That's not all: we'll go one step further and take that ability to create database driven applications onto the mobile platform as well. Just like that.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
785
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Scotch On The Rocks 2011

    1. 1. Database-driven mobile AIR applications The power of ORM
    2. 2. Who Am I?Steven PeetersInstructor / consultant at multimediacollegeTM• Adobe Flex, AIR, Flash Catalyst & ColdFusion Certified Instructor• Adobe Community Professional• ColdFusion User Group Manager• 12+ years of development experience• Flex & AIR since 2004• Author for Friends of ED Email: steven@multimediacollege.be LinkedIn: www.linkedin.com/in/stevenpeeters Twitter: @aikisteve Blog: www.flexpert.be Website: www.multimediacollege.be
    3. 3. Topics• Database in AIR• Using ColdFusion’s ORM• Synchronising with a remote server• Applying to mobile applicationsTwitter hash tag: #airorm
    4. 4. Database in AIR
    5. 5. Database in AIR• SQLite
    6. 6. Database in AIR• SQLite • Lightweight database
    7. 7. Database in AIR• SQLite • Lightweight database • Limited type support
    8. 8. Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use
    9. 9. Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use • Available offline
    10. 10. Database in AIR• SQLite • Lightweight database • Limited type support • Easy to use • Available offline • Synchronous AND asynchronous access
    11. 11. Database encryption
    12. 12. Database encryption• 256-bit AES encryption
    13. 13. Database encryption• 256-bit AES encryption• Use EncryptionKeyGenerator to validate strength of encryption key • as3corelib on code.google.com
    14. 14. Database encryption• 256-bit AES encryption• Use EncryptionKeyGenerator to validate strength of encryption key • as3corelib on code.google.com• Re-ecryption is possible
    15. 15. Using ColdFusion’s ORM
    16. 16. Using ColdFusion’s ORM• Server-side technology on client-side? • cfair.swc • <server root>/CFIDE/Scripts/AIR
    17. 17. Using ColdFusion’s ORM• Server-side technology on client-side? • cfair.swc • <server root>/CFIDE/Scripts/AIR• Works with local database
    18. 18. Using ColdFusion’s ORM• Server-side technology on client-side? • cfair.swc • <server root>/CFIDE/Scripts/AIR• Works with local database• Use SyncManager class
    19. 19. Using ColdFusion’s ORM• Server-side technology on client-side? • cfair.swc • <server root>/CFIDE/Scripts/AIR• Works with local database• Use SyncManager class• Need to adjust DTOs with metadata
    20. 20. Using ColdFusion’s ORM• Server-side technology on client-side? • cfair.swc • <server root>/CFIDE/Scripts/AIR• Works with local database• Use SyncManager class• Need to adjust DTOs with metadata• No BLOB possible :-(
    21. 21. Entity Metadata
    22. 22. Entity Metadata• [Entity]
    23. 23. Entity Metadata• [Entity]• [Table(name=”<name>”)]
    24. 24. Entity Metadata• [Entity]• [Table(name=”<name>”)]• [RemoteClass(alias=”<cfc>”)]
    25. 25. Entity Metadata• [Entity]• [Table(name=”<name>”)]• [RemoteClass(alias=”<cfc>”)]• [Bindable]
    26. 26. Field Metadata
    27. 27. Field Metadata• [Id]
    28. 28. Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”, initialValue=”1”, incrementBy=”1”)]
    29. 29. Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”, initialValue=”1”, incrementBy=”1”)]• [Transient]
    30. 30. Field Metadata• [Id]• [GeneratedValue(strategy=”INCREMENT”, initialValue=”1”, incrementBy=”1”)]• [Transient]• [Column(name=”<name>”, columnDefinition=”TEXT|INTEGER|REAL|DATE”, nullable=”true|false”, unique=”true|false”]
    31. 31. Relationship Metadata
    32. 32. Relationship Metadata
    33. 33. Relationship Metadata• [OneToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]
    34. 34. Relationship Metadata• [OneToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<entity>”, mappedBy=”<entity>”, fetchType=”EAGER(default)|LAZY”)]
    35. 35. Relationship Metadata• [OneToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<entity>”, mappedBy=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [ManyToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]
    36. 36. Relationship Metadata• [OneToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [OneToMany(targetEntity=”<entity>”, mappedBy=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [ManyToOne(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]• [ManyToMany(targetEntity=”<entity>”, fetchType=”EAGER(default)|LAZY”)]
    37. 37. Relationship Metadata
    38. 38. Relationship Metadata• [JoinTable(name=”<name>”)]
    39. 39. Relationship Metadata• [JoinTable(name=”<name>”)]• [JoinColumn(name=”<name>”, referencedColumnName=”<name>”)]
    40. 40. Relationship Metadata• [JoinTable(name=”<name>”)]• [JoinColumn(name=”<name>”, referencedColumnName=”<name>”)]• [InverseJoinColumn(name=”<name>”, referencedColumnName=”<name>”)]
    41. 41. Synchronising with remote server
    42. 42. Synchronising with remote server• Always asynchronous
    43. 43. Synchronising with remote server• Always asynchronous• Using SyncManager class • port • server • syncCFC • session
    44. 44. Synchronising with remote server
    45. 45. Synchronising with remote server• Fetching remote data • syncManager.fetch(“foo”)
    46. 46. Synchronising with remote server• Fetching remote data • syncManager.fetch(“foo”)• Save remote data in local SQLite database • session.saveUpdateCache(<ArrayCollection>)
    47. 47. Synchronising with remote server
    48. 48. Synchronising with remote server• Reading data from local database
    49. 49. Synchronising with remote server• Reading data from local database • session.load(<valueObject>, <filterObject>)
    50. 50. Synchronising with remote server• Reading data from local database • session.load(<valueObject>, <filterObject>) • session.loadAll(<valueObject>)
    51. 51. Synchronising with remote server• Reading data from local database • session.load(<valueObject>, <filterObject>) • session.loadAll(<valueObject>) • session.loadbyPK(<valueObject>, <PK filter>)
    52. 52. Synchronising with remote server• Reading data from local database • session.load(<valueObject>, <filterObject>) • session.loadAll(<valueObject>) • session.loadbyPK(<valueObject>, <PK filter>) • session.loadByQuery(<valueObject>, <SQL where condition>)
    53. 53. Synchronising with remote server
    54. 54. Synchronising with remote server• Saving data to the local database
    55. 55. Synchronising with remote server• Saving data to the local database • session.saveUpdate(<valueObject>)
    56. 56. Synchronising with remote server• Saving data to the local database • session.saveUpdate(<valueObject>) • session.delete(<valueObject>)
    57. 57. Synchronising with remote server
    58. 58. Synchronising with remote server• Pushing data to the remote database
    59. 59. Synchronising with remote server• Pushing data to the remote database • syncManager.autocommit = true
    60. 60. Synchronising with remote server• Pushing data to the remote database • syncManager.autocommit = true • session.commit()
    61. 61. What can you do with it?• Online/offline synchronisation• Use DB as (temporary) storage• Protect private data (encryption)• Colaborate with other people• ...
    62. 62. What can you do with it?
    63. 63. ORM on mobile devices
    64. 64. How hard is it?
    65. 65. ORM on mobile devices
    66. 66. ORM on mobile devices• What’s available?
    67. 67. ORM on mobile devices• What’s available? • SQLite database
    68. 68. ORM on mobile devices• What’s available? • SQLite database • Disk access
    69. 69. ORM on mobile devices• What’s available? • SQLite database • Disk access • Data contract?
    70. 70. ORM on mobile devices• What’s available? • SQLite database • Disk access • Data contract? • WiFi?
    71. 71. ORM on mobile devices
    72. 72. ORM on mobile devices• What’s different?
    73. 73. ORM on mobile devices• What’s different? • AIR 2.5 minimum
    74. 74. ORM on mobile devices• What’s different? • AIR 2.5 minimum • Specify access rights in app.xml
    75. 75. ORM on mobile devices• What’s different? • AIR 2.5 minimum • Specify access rights in app.xml • not much really...
    76. 76. So how hard is it then? “It’s like stealing candy from a baby!”
    77. 77. What can you do with it?
    78. 78. Thank you Twitter: @aikisteve Email: steven@multimediacollege.be Personal site: www.flexpert.be 2 / 12

    ×