Using Oracle 10g CLOB with Grails 2.0.1

I am working on a project using Oracle 10g and Grails v2.0.1.

I am trying to use the CLOB data type for the text input field in the Domain class and it does not seem to work. My first attempt was based on what I read here about GORM , which says to use type: 'text', for example this example:

class Address {
   String number
   String postCode
   static mapping = {
       postCode type: 'text'
   }
}

Grails correlated this with the data type LONGin my database, which is not desirable

The second attempt was to try type: 'clob'. This was effective so that my DB data type would be CLOB, but would result in a class cast error because the property itself was defined as a string, i.e. String postCode. (Note that I never saw type:'clob'in the documentation, but I could deduce from the dialect class what clobmay be a valid input)

Subsequently, I tried to define the property as java.sql.Clob, i.e. Clob postCode;and it didn't work at all. There are no error messages, but nothing is saved in the database.

clob, String, / String Clob. , Clob. Grails , println() . myClob.setString(1, theString) , .

, , Clob , , - . , , ?

... , Grails, postCode type: 'text' clob? Hibernate, , , .

: Grails 1.3.7 2.0.1, , type: 'text' CLOB Oracle. , 2.0.1.

+5
3

, , .

SQL sqlType

.

, , DB CLOB, java String. , , type DB Java ? sqlType , DB.

, :

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

StackOverflow ( , !):

, , . , , - !


... , :

:

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

, , :

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

, , !: D

, . .

+1

Answer Ivan works for me. MaterializedClob - Hibernate JDBC Type for Java String.

0
source

All Articles