WebObjects and Squeryl

Version 136.1 by Ravi Mendis on 2010/11/10 03:11

Squeryl = SQL-like DSL for Scala

Advantages of Squeryl over EOF:

  • Concurrent
    • Spawns multiple database connections
    • Issues database transactions concurrently
  • Scala Actor compatible
    • Immutable object model/graph
  • Strongly-typed
    • Better suited for database/business "logic".
             E.g: Exploits the compiler and IDE to catch exceptions at compile time rather than at run-time.
  • Uses Scala (functional) collection classes

Migrating EOF -> Squeryl

In keeping with the strong-typed philosophy of Scala, Squeryl has no dynamic component like EOF (i.e an EO model file).

EOF has the ability to generate classes in Java (and in Objective-C prior to WebObjects 4.5) as enforcing type has become customary in enterprise environments. We may exploit this feature of EOF to generate a Squeryl schema.

Preparing your EO model

  1. Make sure all EO entities have a class name. i.e there's no support for entities marked as EOGenericRecord.
  2. (Temporary) Ensure all EO entities in your model are in the same package

Generating the Squeryl Schema

  1. Create a .eogen file for your EO model as normal. Only set the File Names extension to "scala".
  2. Use the Squeryl EO Templates:
Warning

Note

Any custom business "logic" will have to be manually re-written in Scala