Search code examples
grailsgrails-orm

Conversion: datetime to time


I am working on legacy database in which there is a table having time as its data type but In Grails when we define a field of type Date then it generates a field of type datetime, is there any way to give instruction in domain so that it generate the corresponding column of type time?


Solution

  • You can use mapping and sqlType

    class MyClass {
        Date myDate
        static mapping = {
            myDate sqlType: "time"
        }
    }
    

    Further info here