GORM还可以通过DSL的type属性来支持Hibernate类型. 包括特定Hibernate的 org.hibernate.usertype.UserType 的子类, which allows complete customization of how a type is persisted. 比如,有一个 PostCodeType 你可以象下面这样使用:class Address {
String number
String postCode
static mapping = {
postCode type:PostCodeType
}
}另外如果你想将它映射到Hibernate的基本类型而不是Grails的默认类型,可以参考下面代码:class Address {
String number
String postCode
static mapping = {
postCode type:'text'
}
}上面的例子将使 postCode 映射到数据库的SQL TEXT或者CLOB类型.