MongoDB issues with Grils Scaffolding (not found in MySQL)

I tried using MongoDB 2.0.6 to replace MySQL 5.5.25 for the Grails 2.1 test application and ran into some weird issues.

Problems using MongoDB but not MySQL:

  • When using Scaffolding, I cannot get order fields using static constraints

  • When I specify inList as a constraint, I get a drop-down menu when using the MySQL backend, but a field when using the MongoDB backend.

  • No * (asterisk) in the fields where the restriction is indicated blank=false.

Domain Class :

package study

class Student {

    String login
    String firstName
    String lastName
    String gender
    Boolean active

    Date dateCreated
    Date lastUpdated

    static constraints = {
        login()
        firstName(blank: false)
        lastName(blank: false)
        gender(inList: ['M', 'F'])
        active()
    }

}

Controller

package study

class StudentController {

    def scaffold = true
}

DataSource.groovy (MySQL stuff commented out):

grails {
  mongo {
    host = "dev-linux"
    port = 27017
    username = "study"
    password= "********"
    databaseName = "study"
  }
}

//dataSource {
//    pooled = true
//    driverClassName = "com.mysql.jdbc.Driver"
//    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect"
//    username = "study"
//    password = "********"
//    dbCreate = "create-drop" // one of 'create', 'create-drop','update'
//    url = "jdbc:mysql://dev-linux:3306/study"
//
//}
//hibernate {
//    cache.use_second_level_cache = true
//    cache.use_query_cache = true
//    cache.provider_class = "net.sf.ehcache.hibernate.EhCacheProvider"
//}

BuildConfig.groovy ( , , MongoDB MySQL, Grails)

plugins {
      // build ":hibernate:$grailsVersion"
      // compile ":mysql-connectorj:5.1.12"

      compile ":mongodb:1.0.0.GA"
      build ":tomcat:$grailsVersion"

}

, MongoDB MySQL, - DataSource.groovy BuildConfig.groovy, .

- , ?

, - Nabble, MongoDB.

.

, , . , .

, .

- Grails + Scaffolding MongoDB ? - - ?

, .

+5
1

MongoDB, , mongodb, grails , . :

  • :

    grails uninstall-plugin hibernate
    

    BuildConfig.groovy:

    runtime ":database-migration:1.1"
    runtime ":hibernate:$grailsVersion"
    
  • , Mongo, :

    static mapWith="mongo"
    
+2

All Articles