Changes for page WebObjects and Squeryl

Last modified by Ravi Mendis on 2011/04/01 11:14

From version 56.1
edited by Ravi Mendis
on 2011/02/27 23:20
Change comment: There is no comment for this version
To version 55.1
edited by Ravi Mendis
on 2011/03/31 23:36
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,4 +1,4 @@
1 -= Squeryl ~= //SQL-like// DSL for Scala =
1 += Squeryl ~= //SQL-like// DSL in Scala =
2 2  
3 3  Advantages of [[Squeryl>>http://squeryl.org/]] over EOF:
4 4  
... ... @@ -7,11 +7,11 @@
7 7  ** Issues database transactions concurrently
8 8  * Scala Actor compatible
9 9  ** Immutable object model/graph
10 -** Fine-grained transaction control
11 -* Strongly-typed
10 +** Explicit transaction control
11 +* Type Safety
12 12  ** Better suited for database/business "logic".
13 13   E.g: Exploits the compiler and IDE to catch exceptions at compile time rather than at run-time.
14 -* Uses Scala collection classes
14 +* Uses Scala Collections
15 15  
16 16  = Migrating EOF -> Squeryl =
17 17  
... ... @@ -45,3 +45,38 @@
45 45  * Optional attributes (i.e those that ##allowsNull##) are typed as ##OptionT##
46 46  * To one relationships that are not mandatory (i.e optional relationships) are also typed as ##OptionT##
47 47  * To many relationships are represented as a Squeryl iterable (collection class) as opposed to a ##NSArray##.
48 +
49 +=== Use of Scala Collections ===
50 +
51 +===== 1. Filtering =====
52 +
53 +Instead of using EOQualifiers to filter EOs dynamically, you can apply the type safe filter in Scala:
54 +
55 +{{code}}
56 +
57 +def activeFiles = files.filter(_.active == true)
58 +
59 +{{/code}}
60 +
61 +===== 2. Iteration =====
62 +
63 +Functional language iteration that's become increasingly popular can be used:
64 +
65 +{{code}}
66 +
67 +activeFiles.foreach(f => {
68 + ...
69 +})
70 +
71 +{{/code}}
72 +
73 +===== 3. For-Comprehensions =====
74 +
75 +{{code}}
76 +
77 +
78 +Here's just an example use of sequence comprehension:
79 +
80 +def activeFiles = for (file <- files if file.active == true) yield f
81 +
82 +{{/code}}