Key Points
- Gorm is an ORM for RDBs ( specifically MySQL,Postgres, MS SQL, sqlite ) with the ability to create dialects to support other databases
- Gorm uses Groovy scripting to define data models and relations
- Gorm models can be used in Grails to scaffold Web applications and REST services
References
Key Concepts
Groovy 3 Key Features
http://groovy-lang.org/releasenotes/groovy-3.0.html
supports JDK 11, JDK 9 and JDK 8 at runtime
onlyJDK 11, JDK 9 supported at build time
Java-style Lambda syntax
The Java syntax for lambda expressions is now supported.
Examples:
(1..10).forEach(e -> { println e })
assert (1..10).stream()
.filter(e -> e % 2 == 0)
.map(e -> e * 2)
.toList() == [4, 8, 12, 16, 20]
The normal variants are supported and Groovy adds additional features such as default parameter values:
// general form
def add = (int x, int y) -> { def z = y; return x + z }
assert add(3, 4) == 7
// curly braces are optional for a single expression
def sub = (int x, int y) -> x - y
assert sub(4, 3) == 1
// parameter types are optional
def mult = (x, y) -> x * y
assert mult(3, 4) == 12
// no parentheses required for a single parameter with no type
def isEven = n -> n % 2 == 0
assert isEven(6)
assert !isEven(7)
// no arguments case
def theAnswer = () -> 42
assert theAnswer() == 42
// any statement requires braces
def checkMath = () -> { assert 1 + 1 == 2 }
checkMath()
// example showing default parameter values (no Java equivalent)
def addWithDefault = (int x, int y = 100) -> x + y
assert addWithDefault(1, 200) == 201
assert addWithDefault(1) == 101
Potential Value Opportunities
Potential Challenges
Bug> Groovyconsole can't open groovy file from menu or cli
bug> can't open a file from groovyconsole using the file menu
workaround> use CTL + O
- open groovyconsole normally
- use CTL + O to open file selector window
- select a groovy file
- press Enter
- << file opens normally in groovy console
Candidate Solutions
Step-by-step guide for Example
sample code block