Search code examples
javaoracle-databasehibernategrailsgrails-orm

Error when use PropertyNotInList in Grails + Oracle + CLOB


I'm trying to retrieve all objects from oracle 11g database except some objects that contain an especial value in a property.

The code:

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

The attribute thoughts must be CLOB because I just have permission to CRUD data. I can't use any DDL statement.

With that, I got ORA-00932 error.

ORA-00932: inconsistent datatypes: expected - got CLOB

My Domain Class:

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
    }
}

How can I solve that?


Solution

  • thoughts should be of type: "text" in the domain class if it is treated as CLOB. Can you share the Question domain class? And why params in the dynamic finder?

    Something like this:

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