Squeryl = SQL-like DSL in Scala

Advantages of Squeryl over EOF:

Migrating EOF -> Squeryl

In contrast to EOF Squeryl maintains its ORM information programmatically - in the classes itself and collectively in a schema. In keeping with the strongly-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) because enforcing type has become customary in enterprise environments. We may exploit this feature of EOF to generate a Squeryl schema from an EO model.

Preparing your EO model

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:

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

Differences Between a Squeryl Schema and EO Model/Classes

Use of Scala Collections

1. Filtering

Instead of using EOQualifiers to filter EOs dynamically, you can apply the type safe filter in Scala:

def activeFiles = files.filter(_.active == true)
2. Iteration

Functional language iteration that's become increasingly popular can be used:

activeFiles.foreach(f => {
   ...
})
3. For-Comprehensions

Here's just an example use of sequence comprehension:

def activeFiles = for (file <- files if file.active == true) yield file