Grails 1.3.7 Интеграция GORM с БД Oracle 10g приводит к появлению «Ошибка SQL: 932, SQLState: 42000» для сопоставления атрибута класса домена с типом Orable CLOB - PullRequest
1 голос
/ 14 декабря 2011

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

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

(текстовое содержимое, которое я пытаюсь сохранить,HTML code)

У меня такой вопрос: как сохранить текстовое содержимое (например, 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

1 Ответ

1 голос
/ 12 марта 2012

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

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

...