Интеграция Grails 1.3.7 GORM с Oracle 10g DB приводит к ошибке SQL: 932, SQLState: 42000 для сопоставления атрибутов класса домена с типом Orable CLOB

Я получаю именно ту проблему, которая описана в: http://www.bedework.org/trac/bedework/ticket/58

Проблема возникает, когда класс обслуживания вызывает save() для класса домена, у которого есть атрибут ("String contentText"), настроенный для сохранения в качестве типа данных CLOB в базе данных Oracle 10g (выбран CLOB, поскольку я хочу хранить тексты длиннее, чем 4000 символов, Varchar2 не поддерживает более 4000 символов).

(Текстовое содержимое, которое я пытаюсь сохранить, представляет собой HTML-код)

Мой вопрос: как сохранить текстовое содержимое (например, HTML-код) в типизированном поле CLOB в БД Oracle 10g с помощью GORM в Grails 1.3.7?

Большое спасибо за помощь! /Герман

Выдержка из журнала:

2011-12-14 15:06:53,564 DEBUG JDBCExceptionReporter:92 - could not execute query [select this_.id as id4_0_, this_.version as version4_0_, this_.activation_price as activation3_4_0_, this_.active as active4_0_, this_.content_text as content5_4_0_, this_.country_code as country6_4_0_, this_.customer_type as customer7_4_0_, this_.danish_db_id as danish8_4_0_, this_.data_cap_type as data9_4_0_, this_.expiry_date as expiry10_4_0_, this_.group_name as group11_4_0_, this_.is_minimum_commitment as is12_4_0_, this_.is_pott as is13_4_0_, this_.launch_date as launch14_4_0_, this_.main_image as main15_4_0_, this_.monthly_price as monthly16_4_0_, this_.name as name4_0_, this_.pdf as pdf4_0_, this_.product_id as product19_4_0_, this_.time_of_notice as time20_4_0_, this_.type as type4_0_, this_.usp1 as usp22_4_0_, this_.usp2 as usp23_4_0_, this_.usp3 as usp24_4_0_, this_.version_comment as version25_4_0_ from price_plan this_ where (this_.activation_price=? and this_.active=? and this_.content_text=? and lower(this_.country_code)=? and lower(this_.customer_type)=? and this_.danish_db_id=? and lower(this_.expiry_date)=? and lower(this_.group_name)=? and this_.is_minimum_commitment=? and this_.is_pott=? and lower(this_.launch_date)=? and this_.monthly_price=? and lower(this_.name)=? and lower(this_.product_id)=? and this_.time_of_notice=? and lower(this_.type)=?)]
java.sql.SQLSyntaxErrorException: ORA-00932: inconsistent datatypes: expected - got CLOB
    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91)
    ... 
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
2011-12-14 15:06:53,589  WARN JDBCExceptionReporter:100 - SQL Error: 932, SQLState: 42000
2011-12-14 15:06:53,592 ERROR JDBCExceptionReporter:101 - ORA-00932: inconsistent datatypes: expected - got CLOB

person hbartling    schedule 14.12.2011    source источник


Ответы (1)


Вы должны сопоставить столбец с правильным типом, например:

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

Это заставит столбец postCode сопоставляться с типом SQL TEXT или CLOB в зависимости от используемой базы данных.

Источник: http://grails.org/doc/1.0.x/guide/5.%20Object%20Relational%20Mapping%20(GORM).html

person rodvlopes    schedule 12.03.2012