in my domain object i have a map:
Map<String, String> stuff
GORM automatically creates a table where the key and the value are varchar(255).
i need the value to be LongText instead. How do i do this thing?
Also, is there a workaround for this that doesnt involve using the hibernate config?
db. Model is the ordinary way of doing things. It allows you to tell gorm which model struct this operation relates to. It isn't always needed, as for example a simple Find with the right struct type will infer the model automatically.
You can get the MySQL table columns data type with the help of “information_schema. columns”. SELECT DATA_TYPE from INFORMATION_SCHEMA. COLUMNS where table_schema = 'yourDatabaseName' and table_name = 'yourTableName'.
It uses the name of your type. Here the type is User so gorm will use the users table by default. You can also configure it to not use the plural form if you'd like.
GORM provides First , Take , Last methods to retrieve a single object from the database, it adds LIMIT 1 condition when querying the database, and it will return the error ErrRecordNotFound if no record is found. // Get the first record ordered by primary key. db.First(&user)
I think you can declare this setting in the mapping closure of your Domain class.
Constraint for a String field so that its MySQL column type is TEXT:
static mapping = {
myTextField type: 'text'
}
Maybe this can help you out: Grails Guide (5.5.2.1 Table and Column Names)
I'm afraid only via Hibernate XML config and specifying a key
mapping for the stuff
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With