StORM preview
Upcoming SlideShare
Loading in...5
×
 

StORM preview

on

  • 571 views

Introducing a new ORM for Android SQLite.

Introducing a new ORM for Android SQLite.

Statistics

Views

Total Views
571
Views on SlideShare
570
Embed Views
1

Actions

Likes
1
Downloads
4
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    StORM preview StORM preview Presentation Transcript

    • stORM preview +David Chandler Android Developer Advocate http://turbomanage.comTuesday, November 13, 12
    • simple template-based Object I E W Relational R E V Mapping PTuesday, November 13, 12
    • why hand-coded SQL, ugh SQLite already has obj-like wrappers - ContentValues (insert, update) - Cursor (query) many apps just require a place to stuff some objects existing ORMs use reflection or require up-front modelingTuesday, November 13, 12
    • goals easy convention over configuration annotation-driven - @Database, @Entity - seamless code gen with JDT easy to debug minimal performance overheadTuesday, November 13, 12
    • non-goals kitchen sink model all relations absolute max performanceTuesday, November 13, 12
    • setup 1. add storm-api.jar to libs/ 2. add storm-apt.jar to annotation factory classpathTuesday, November 13, 12
    • use Extend DatabaseHelper, annotate with @Database POJOs implement Persistable, annotate with @Entity Generates - DbFactory - EntityTable - EntityDao new EntityDao(ctx).insert/get/query...Tuesday, November 13, 12
    • use dao.insert(T obj) dao.insertMany(Iterable<T> objs) T dao.get(long id) dao.update(T obj) dao.delete(long id) / dao.deleteAll() List<T> dao.listAll() dao.listAllByExample(T exampleObj) dao.filter().eq(COL, val).eq(...).exec()Tuesday, November 13, 12
    • conventions COLNAME == fieldName.toUpperCase() id - long id (required) - column name is _IDTuesday, November 13, 12
    • supported types all primitives & wrappers - boolean, byte, byte[], char, double, enum, float, int, long, short, String - byte[] have affinity BLOB - boolean, byte, char have affinity INTEGER roll-your-own - extend TypeConverter<J,S> - annotate with @ConverterTuesday, November 13, 12
    • nice List<T> dao.listByExample(T obj) T dao.getByExample(T obj) - throws TooManyResultsException insertMany uses 1 transaction column name enum in Table class - filter().eq(Columns.FIRSTNAME, “David”)... red squigglies from APTTuesday, November 13, 12
    • csv dao.getDatabaseHelper(ctx) dbHelper.backupAllTablesToCsv() dbHelper.restore...FromCsv() exact type conversions - blobs are Base64 encoded - doubles saved as raw hex values file named dbName.vn.TableNameTuesday, November 13, 12
    • UpgradeStrategy DROP_CREATE BACKUP_RESTORE (csv) - dropped cols disappear - new cols get default values - renaming not yet supported UPGRADE - override DatabaseHelper.upgrade() and/or - override TableHelper.onUpgrade(...) for eachTuesday, November 13, 12
    • limits no relations (yet) can’t compare doubles or blobs with FilterBuilder.eq() - likely add .eq(COL, val, delta) - or dao.query(String where, String[] args)Tuesday, November 13, 12
    • dbFactory static db name, version singleton instance of DatabaseHelper getTableHelpers()Tuesday, November 13, 12
    • dao extends SQLiteDao<T> - most of the code lives in the base class points to DatabaseFactory points to TableHelperTuesday, November 13, 12
    • table all SQL all getX() / bindX() Cursor --> obj --> ContentValues obj --> String[] (for csv)Tuesday, November 13, 12
    • impl how to support incremental compilation? - anno processing happens in rounds - full src not available in every round - stormEnv file under .apt_generated - TypeConverters aren’t there yet - if in doubt, Project | Clean Freemarker templates in impl/src/res watch the Error Log viewTuesday, November 13, 12
    • future limited relations (@Key) more filter methods gt(), lt(), etc. @Id for custom id col @Column(name=”custom”) part of ADT?Tuesday, November 13, 12
    • src drfibonacci.googlecode.comTuesday, November 13, 12
    • native http Apache HttpClient HttpUrlConnection google-api-java-client google-http-java-client basic-http-clientTuesday, November 13, 12
    • basic-http-client just the basics sync api w/ smart error handling async api - automatically wraps in AsyncTask - auto retry / backoff extensible - RequestLogger - RequestHandlerTuesday, November 13, 12
    • src basic-http-client.googlecode.comTuesday, November 13, 12
    • R developer.android.com Common Tasks Google I/O sessions +Android Developers turbomanage.com (my blog)Tuesday, November 13, 12