This question is similar to this post – but the answer does not apply here. I am currently only working in development and configured as dbCreate: create-drop
with url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
Using Grails 3.0.11 – GORM seems to not recognize type:'text' mapping. Here is my model:
package mypackage
class Text extends Object {
String body
Media image
boolean textFirst = true
static constraints = {
image nullable:true
}
static mapping = {
body type: 'text'
}
}
Bootstrapping some data, I'm being thrown this error:
ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Value too long for column "BODY VARCHAR(255)": "'<p>some copy... (1222)"; SQL statement:
insert into object (id, date_created, description, heading, last_updated, title, two_col, body, image_id, text_first, class) values (null, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'mypackage.Text')
My understanding is that the mapping
to type:text
should create CLOB-type variable, which is automatically not constrained to max size 255.
Attempted Solutions
grails clean
- application is cleaned, no successgrails clean-all
- this isn't a Grails 3+ method (does not work)grails clean --refresh-dependencies
– cleans, but no success- Swapped the order of
static constraints
andstatic mapping
in the model, no success - Added
body maxSize: 5000
to my model constraints , no success grails url-mappings-report
strangely completes the Bootstrap without throwing an error.
Edit 1
This might have to do with inheritance – the Text Class currently extends Object. Changing the Text model as follows, Bootstrapping succeeds. Could anyone provide me with some insight?
package mypackage
class Text {
String body
Media image
boolean textFirst = true
static constraints = {
image nullable:true
}
static mapping = {
body type: 'text'
}
}
This is the mypackage.Object:
package mypackage
class Object {
String title
String heading
String description
Date dateCreated
Date lastUpdated
boolean twoCol = false
static constraints = {
heading nullable: true, maxSize: 3000
description nullable: true, maxSize: 500
}
static mapping = {
version false
}
}
Edit 2
Renamed the body
container to content
, grails clean
and it seems to be working now. Still unsure of what was going on, maybe some sort of caching issue (?) ...
Any help is awesome!! Thank you all :)