@CompileStatic class GrailsGormOptions extends java.lang.Object implements java.io.Serializable
GORM compilation options, configured through the nested grails { gorm { }} block:
grails {
gorm {
defaultIdType = 'native'
}
}
| Type | Name and description |
|---|---|
Property<java.lang.String> |
defaultIdTypeThe type of the id GORM adds to a domain class that declares none of its own. |
| Constructor and description |
|---|
GrailsGormOptions(ObjectFactory objects) |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
The type of the id GORM adds to a domain class that declares none of its own.
'long', the default, gives every domain class a Long id, as every earlier
Grails release did. 'native' gives it the identity type of the GORM implementation it is
mapped with: a MongoDB domain class is given a String id, holding the hexadecimal form of
a generated ObjectId, while a Hibernate one keeps Long.
This is resolved when the domain class is compiled, from its mapWith property and the
GORM implementations on the compilation classpath, so an application using more than one
implementation gets the right type for each domain class from the single setting. A domain class
that declares an id keeps the type it declares either way.
Changing this changes the type of a column or field that already holds data. It is a setting to choose when an application is written, not one to turn on later without migrating what has already been stored.