【问题标题】:Error when use PropertyNotInList in Grails + Oracle + CLOB在 Grails + Oracle + CLOB 中使用 PropertyNotInList 时出错
【发布时间】:2013-04-30 16:17:03
【问题描述】:

我正在尝试从 oracle 11g 数据库中检索所有对象,除了某些在属性中包含特殊值的对象。

代码:

//Retrieve thoughts
def thoughts = Question.findAllByThoughtsNotInList(["-", "", null], params)
def totalThoughts = Question.countByThoughtsNotInList(["-", "", null])

属性thoughts 必须是CLOB,因为我只有CRUD 数据的权限。我不能使用任何 DDL 语句。

这样,我得到了ORA-00932 错误。

ORA-00932: inconsistent datatypes: expected - got CLOB

我的领域类:

class Question {
    String person
    String thoughts 

    static constraints = {
        thoughts nullable: true
    }

    static mapping = {
        table "Question"
        id name: "person"
        person column: "person"
        thoughts column: "thoughts_person"
        version false
    }
}

我该如何解决?

【问题讨论】:

  • 映射有点混乱。 id for Question 是 person? thoughts 映射到哪里?

标签: java oracle hibernate grails grails-orm


【解决方案1】:

thoughts 在域类中应该属于type: "text",如果它被视为 CLOB。可以分享Question 域类吗?为什么要在动态查找器中使用params?

类似这样的:

class Question {
    String thoughts 

    static mapping = {
        table "QUESTION"
        id column: "QUESTION_ID"
        thoughts column: "THOUGHTS", type: "text"
    }
}

【讨论】:

  • 看看我的编辑。希望我传达了我想要表达的意思。
猜你喜欢
  • 2015-10-24
  • 2012-05-08
  • 2021-05-10
  • 1970-01-01
  • 2016-09-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-15
相关资源
最近更新 更多