Grails没有在propper数据库中保存域类

时间:2012-11-24 03:20:09

标签: mysql grails grails-2.0

我有一个grails(2.0)应用程序需要从多个MySQL数据库中获取某些信息。我不能因为上帝的爱而得到它来保存适当数据库中的域类。

我的Datasource.groovy文件是这样的:

environments {
development {
    dataSource {
        dbCreate = "create-drop"
        url = "jdbc:mysql://localhost:3306/informacion_empleados_dev"
    }
    dataSource_signOn {
        driverClassName = "com.mysql.jdbc.Driver"
        username = "root"
        password = ""
        dbCreate = "create-drop"
        url = "jdbc:mysql://localhost:3306/sign_on"
    }
    dataSource_administradores {
        driverClassName = "com.mysql.jdbc.Driver"
        username = "root"
        password = ""
        dbCreate = "create-drop"
        url = "jdbc:mysql://localhost:3306/administradores"
    }
    dataSource_docentes {
        driverClassName = "com.mysql.jdbc.Driver"
        username = "root"
        password = ""
        dbCreate = "create-drop"
        url = "jdbc:mysql://localhost:3306/docentes"
    }
    dataSource_alumnos {
        driverClassName = "com.mysql.jdbc.Driver"
        username = "root"
        password = ""
        dbCreate = "create-drop"
        url = "jdbc:mysql://localhost:3306/alumnos"
    }
}

我的每个域类都将它们作为此

引用
class Alumno {

static constraints = {      
    matricula   blank: false
    nombres     blank: false
    apellidos   blank: false
}

static mappings = {
    datasource  'alumnos'
}
}

1 个答案:

答案 0 :(得分:1)

在您的域类中,它应该是mapping而不是mappings

static mapping = {
    datasource  'alumnos'
}