Introducing SOFA an Adobe Air ORM for SQlite

We’re currently working on an ORM for Air/SQlite, it will be released as an open source project in a few weeks. It has support for nested fetching, cascade saving and deleting, many to many + one to many relationship, inheritance, formulas and more. It’s not an activerecord pattern, it’s more like hibernate. By the way, it requires some xml configuration files and currently has no support for conventions… maybe in the next release. Activerecord is a wonderfull pattern but we wanted it to provide nested fetching and cascade saving with a “no more line” way. Here is a quick example of the SofaQL :

Family family = sofaManager
  .createQuery("load Family <=> f where f.id = :id; fetch Family.people")
  .setIntegerArgument("id", 1)
  .execute();

will produce :

Handle LOAD : LOAD Family
executing :
 SELECT Family.ID AS Family_0_id, Family.NAME AS Family_0_name
 FROM FAMILY Family
 WHERE Family.ID = 1
fetching : fetch Family.people
executing :
 SELECT Person.ID AS Person_0_id, Person.NAME AS Person_0_name,
 Person.ID AS Person_0_id, Person.FAMILY_ID AS Person_0_familyId
 FROM ( ( People Person INNER JOIN  SuperPeople SuperPerson
 ON SuperPerson.ID = Person.ID ) Person ) Person
 WHERE Person.FAMILY_ID = 1
result =
 (Family)#0
  id = 1
  name = "pezel"
  people = (mx.collections::ArrayCollection)#1
   filterFunction = (null)
   length = 1
   list = (mx.collections::ArrayList)#2
    length = 1
    source = (Array)#3
     [0] (Person)#4
      familyId = 1
      id = 1
      name = "arnaud"
    uid = "A126F4E4-D083-68E2-0F34-723C76CA1A9C"
  sort = (null)
  source = (Array)#3

Here Person extends SuperPerson, the last query is a little dirty but it allows to handle n-level inheritance on one to many and many to many relationships.

Oh ! and Sofa means “Simple orm for air”. It’s also the place where this project started.

It’ll probably be delivered on google code quickly. Stay tuned !

Comments

4 Responses to “Introducing SOFA an Adobe Air ORM for SQlite”

  1. johannes on novembre 12th, 2008 14:21

    mmm, i would like this now.
    i am moving large chunks of hibernate stuff over to air, right pain.
    i unit test so i can file bug reports :)

  2. RIABG - Онлайн издание за RIA технологии on novembre 18th, 2008 10:55

    [...] ORM за Air/SQlite, ще се появи като open source проект след няколко седмици. Публикувано в Adobe Air | Trackback [...]

  3. DannyT on janvier 19th, 2009 20:59

    Is there any update on this? Looks like just what I’m after.

  4. Jay Godse on janvier 31st, 2009 4:46

    Interesting approach. I guess it is better for those who prefer your query language. I personally prefer straight SQL into SQLite, but I realize that I need to know this ORM way of doing queries if i am to gain any of the efficiencies offered by ActiveRecord and other ORMs.

    SQLite is pretty powerful by itself. You can roll triggers right into the database which gives you some of this cascade on delete.

Leave a Reply