I've been using Hibernate for a while now in Java / Groovy projects, but I tend to not use it directly from my service layer.  Instead, I've found it simpler / more testable / more portable to still use the DAO pattern, wrapping Hibernate functionality.  Instead of the tedious process of writing tons of DAOs, though, I write a "generic" DAO, implementing domain-object specific methods as needed.

I've cooked up a similar DAO for use with CF9, available for download here.

It relieves you of knowing much of any of the CF 9 ORM specifics, letting you quickly get your job done.  Here's the nickel tour of the API:

  1. save( target : Object, noFlush : Boolean = false ) - Saves an instance.  Sending noFlush = true will not commit the transaction (no ormFlush() call).
  2. delete( target : Object, noFlush : Boolean = false ) - Deletes an instance.  Sending noFlush = true will not commit the transaction (no ormFlush() call).
  3. deleteById( entityName : String, id : *, noFlush : Boolean = false ) - Calls delete() after read()ing the instance identified
  4. read( entityName : String, id : * ) - E.g.  read( "Contact", 2 )
  5. list( entityName : String, whereClause : String, params ) - E.g. read ("Contact", "firstName = ?, active = ?", [ "Joe", true ] )

It also exposes a dynamic finder (via onMissingMethod), in the form of list{EntityName}By{Prop1}And{Prop2}And...{PropN}, letting the above list() example be rewritten:

  1. listContactByFirstNameAndActive( "Joe", true )