1
votes

I am inserting a JSON value into a H2 database using GORM in the domain i have two column String clobs Date date

static mapping = {
    datasource 'json'
    clobs sqlType: 'clob'
}

static constraints = {
}

} from the controller i call the service method def createJson(){

    log.debug("Inserting Values")

    def builder = new JsonBuilder()
    builder.message {
        header {
            from('mrhaki')
            to 'Groovy Users', 'Java Users'
        }
        body "Check out Groovy's gr8 JSON support."
    }
    println "builder value before inserting is: "+ builder

    def jsonExec = new JsonOrm(clobs: builder.toString(), date: new Date())
    println "the builder value: "+ jsonExec.clobs
    println "the date value: " + jsonExec.date
    jsonExec.save()(failOnError:true)
    println "values saved successfully in the table!!!!!"
}

while executing this is the error i am getting in the browser URI /SampleProject/jsonOrm/index Class groovy.lang.MissingMethodException Message No signature of method: com.ws.JsonOrm.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[failOnError:true]] Possible solutions: wait(), last(), save(), any(), getAll(), wait(long)

2
Please be as specific as possible when asking questions on SO. - Chris

2 Answers

0
votes

To render a json string (from the CLOB), you can just parse string first and then render the json from it like this:

Map map = JSON.parse(jsonString)
render (map as JSON)
0
votes

You're converting the entire CLOB object, you just want the 'contents', try:

stmt = row["JSON"]?.asciiStream.text