Wiki source code of WebObjects and Squeryl
Version 108.1 by Ravi Mendis on 2010/11/10 05:43
Hide last authors
author | version | line-number | content |
---|---|---|---|
![]() |
81.1 | 1 | = Squeryl ~= //SQL-like// DSL for Scala = |
![]() |
54.1 | 2 | |
![]() |
107.1 | 3 | Advantages of Squeryl over EOF: |
![]() |
54.1 | 4 | |
5 | * Concurrent | ||
6 | ** Spawns multiple database connections | ||
7 | ** Issues database transactions concurrently | ||
8 | * Scala Actor compatible | ||
9 | ** Immutable object model/graph | ||
![]() |
81.1 | 10 | * Strongly-typed |
![]() |
54.1 | 11 | ** Better suited for database/business "logic". |
12 | E.g: Exploits the compiler and IDE to catch exceptions at compile time rather than at run-time. | ||
![]() |
85.1 | 13 | * Uses Scala (functional) collection classes |
![]() |
54.1 | 14 | |
15 | = Migrating EOF -> Squeryl = | ||
16 | |||
![]() |
103.1 | 17 | In contrast to EOF Squeryl maintains its ORM information programmatically - in the classes itself and collectively in a [[schema>>http://squeryl.org/schema-definition.html]]. In keeping with the strongly-typed philosophy of Scala, Squeryl has no dynamic component like EOF (i.e an EO model file). |
![]() |
54.1 | 18 | |
![]() |
85.1 | 19 | 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. |
![]() |
54.1 | 20 | |
21 | === Preparing your EO model === | ||
22 | |||
![]() |
85.1 | 23 | * Make sure **all** EO entities have a class name (including abstract many-To-many "join" tables). There's no support for entities marked as ##EOGenericRecord##. |
![]() |
91.1 | 24 | * Mark the abstract many-To-Many join entities as ##Abstract##. |
![]() |
99.1 | 25 | * (Temporary) Ensure all the model entities are in the same package. i.e the package is exclusive to the model. |
![]() |
54.1 | 26 | |
27 | === Generating the Squeryl Schema === | ||
28 | |||
29 | 1. Create a .eogen file for your EO model as normal. Only set the ##File Names## extension to "scala". | ||
30 | 1. Use the Squeryl EO Templates: | ||
31 | |||
32 | * | ||
33 | ** Entity.eotemplate [[template>>WOL:Squeryl _Entity.eotemplate]] | ||
34 | ** Entity.eotemplate [[template>>WOL:Squeryl Entity.eotemplate]] | ||
35 | |||
36 | {{note title="Note"}} | ||
37 | |||
38 | Any custom business "logic" will have to be manually re-written in Scala | ||
39 | |||
40 | {{/note}} | ||
![]() |
99.1 | 41 | |
42 | == Differences Between a Squeryl Schema and EOF Classes == | ||
43 | |||
![]() |
103.1 | 44 | * Optional attributes (i.e those that ##allowsNull##) are typed as ##OptionT## |
![]() |
105.1 | 45 | * Relationships that are not mandatory (i.e optional relationships) are also typed as ##OptionT## |
46 | * ToMany relationships are represented as a Squeryl iterable (collection class) as opposed to a ##NSArray##. |