#1522 Fanbatis

kaushik Thu 5 May 2011

Fanbatis is a Fantom wrapper for mybatis and also the default ORM that ships with tales(as of v0.3). On the java world, I think mybatis perfectly hits the sweet middle-ground by providing just as much abstraction as required and no more. I extracted Fanbatis out of tales into its own project for better maintenance and for it be useful outside of tales (or when using slan or spectre web frameworks)

Here's the link to the screen-cast and documentation: http://www.talesframework.org/fanbatis/

Here are a few examples of using Fanbatis:

Query using Sql Maps

class BlogSqlMap : SqlMap{
  @Select
  Blog[] getBlogsByAuthor(Int authorId, Int limit){`
     list(sql<|
      select * from blog 
             where author_id = #{authorId}
                      limit 0, #{limit}
    |>)
   }
}

.. then

Blog[] blogs := BlogSqlMap()->getBlogsByAuthor(1, 10)

Query Using Short-hand Syntax

Blog[] blogs := Blog{authorId = 1}.list

Ad-hoc Queries

Row[] rows := DB.queryList("select * from blog where author_id = #{param.authorId}", 
                             ["authorId": 1])

Thanks!

andy Thu 5 May 2011

Looks sweet Kaushik!

Login or Signup to reply.