Ajay Kumar Jaiswal
Ajay Kumar Jaiswal

Reputation: 31

Mapping Clob type in grails domain class with postgresql text type

I am using the code is working for Derby, MySQL, Oracle but it's throwing error while using with PostgreSQL I'm getting error org.hibernet.exception.DataException could not execute the query.

I'm getting a solution to map text with String. But nowhere solution is for map text with Clob in domain class.

class Ticket {
    String id
    String name
    String customerId
    int severity
    Clob description
    String component
    Clob screenshot

    static mapping = {
        version false
        table 'MY_TICKET'
        id generator: 'assigned'
        columns {
            id column: 'TICKET_ID'
            customerId column: 'CUSTOMER_ID'
        }
    }

    static constraints = {
        id bindable: true
    }   
}

Upvotes: 1

Views: 486

Answers (1)

Omsairam
Omsairam

Reputation: 370

You need to change the Clob type to String Type

class Ticket {
    String id
    String name
    String customerId
    int severity
    String description
    String component
    String screenshot

    static mapping = {
        version false
        table 'MY_TICKET'
        id generator: 'assigned'
        columns {
            id column: 'TICKET_ID'
            customerId column: 'CUSTOMER_ID'
        }
    }

    static constraints = {
        id bindable: true
    }  

     component sqltype:'text'
     screenshot sqltype:'text'
}

When we need to use a clob type in our mapping we always model it as a String with mapping type: 'text'.

Upvotes: 1

Related Questions