Using Oracle 10g CLOB with Grails 2.0.1 Using Oracle 10g CLOB with Grails 2.0.1 oracle oracle

Using Oracle 10g CLOB with Grails 2.0.1


I think I found an answer tucked into the documentation on Custom Hibernate Types.

In that case, override the column's SQL type using the sqlType attribute

This appears to be working.

Looks like I'm able to use that to force my DB type to be CLOB while keeping the java type a String. In other words, maybe type chooses both a DB type and a Java type for handling the field? But sqlType gives a little more granularity to specify the DB type to use.

So the sample Domain class above should look like this in my case:

class Address {    String number    String postCode    static mapping = {        postCode sqlType: 'clob'    }} 

I gleaned this from another StackOverflow question on the topic (the question itself clued me in, whereas the accepted answer misled me!):

I spent a day trying to figure this all out, and it was incredibly frustrating. So maybe my notes on the topic here will help someone else avoid that experience!


And while I'm keeping notes here... this post proved somewhat useful in terms of troubleshooting how to get more specific in my mappings:

Interesting code from that is reproduced here:

//CONFIG.GROOVY (maps a custom SixDecimal type)grails.gorm.default.mapping = {    'user-type'( type: SixDecimalUserType, class: SixDecimal )}


Probably too late but I have found a really simple solution to this problem:

class MyDomain{  String myField  ...  static mapping = {        myField type:'materialized_clob'          }}

Nothing else is required, writes and reads works like charm! :D

Hope it helps.Ivan.


Ivan's answer works for me. MaterializedClob is the Hibernate JDBC type for a Java String.