I created an employee domain class using java.util.Date
for a birthday attribute. That was mapped to Datetime (date + time which I don't want) in my MySQL database. So I tried java.sql.Date
which results in the right datatype in my table, unfortunately there is an error in my Grails application saying:
Could not find matching constructor for: java.sql.Date(java.util.Date)
domain class:
package sample
class Mitarbeiter {
String name
java.sql.Date geburtstag
static constraints = {
name()
birthday()
}
}
controller:
package sample
class MitarbeiterController {
def scaffold = Mitarbeiter
}
I'm guessing that the controller scaffolding is not capable of matching the 2 dates.
What happens if you define the mapping like this (docs are here):
class Mitarbeiter {
String name
Date geburtstag
static constraints = {
name()
birthday()
}
static mapping = {
geburtstag sqlType: "date"
}
}