In many classes in my project, I have a String description
and static mapping = { description sqlType: 'MEDIUMTEXT' }
.
Is there anyway to declare a StringMediumText description
which automatically links to a column in the database with sqlType: 'MEDIUMTEXT'
?
So in the future I just need to declare:
Person {
StringMediumText description
}
You can do it by defining your own Hibernate user type
class Person {
String description
static mapping = {
description type: StringMediumTextType
}
}
You find everything regarding your question in the Reference Guide. Hope this helps