How to generate Random Id using ObjectId in grails 2.2.2 and mongoDb ??

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to generate Random Id using ObjectId in grails 2.2.2 and mongoDb ??

sagarmane08
Domain Class :-

class User {
    ObjectId id
    String username
    String password
 
    static mapWith = "mongo"

    static constraints = {
    }
}

Dependencies :-

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

        grailsPlugins()
        grailsHome()
        grailsCentral()

        mavenLocal()
        mavenCentral()

        // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories
        //mavenRepo "http://snapshots.repository.codehaus.org"
        //mavenRepo "http://repository.codehaus.org"
        //mavenRepo "http://download.java.net/maven/2/"
        //mavenRepo "http://repository.jboss.com/maven2/"
    }

    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g.

        // runtime 'mysql:mysql-connector-java:5.1.20'
                compile 'org.imgscalr:imgscalr-lib:4.1'
    }

    plugins {
        runtime ":hibernate:$grailsVersion"
        runtime ":jquery:1.8.3"

        runtime ":resources:1.1.6"

        // Uncomment these (or add new ones) to enable additional resources capabilities
        runtime ":zipped-resources:1.0"
        runtime ":cached-resources:1.0"
        //runtime ":yui-minify-resources:0.1.4"

                compile ":cache-headers:1.1.5"

        build ":tomcat:$grailsVersion"

        runtime ":database-migration:1.2.1"

        compile ':cache:1.0.1'

                compile ":rest:0.7"

                compile ":rendering:0.4.4"

                compile ":mail:1.0.1"

                compile ":oauth:2.1.0"

                compile ":spring-security-core:1.2.7.3"

                compile ":spring-security-ui:0.2"  

                compile ":jquery-ui:1.8.24"

                compile ":famfamfam:1.0.1"

                compile ":calendar:1.2.1"

    }
}


Error 2014-8-28 09:42:48,117 [localhost-startStop-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: No converter found capable of converting from type java.lang.Long to type org.bson.types.ObjectId
Message: No converter found capable of converting from type java.lang.Long to type org.bson.types.ObjectId
    Line | Method
->>  475 | handleConverterNotFound          in org.springframework.core.convert.support.GenericConversionService
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    175 | convert                          in     ''
|    154 | convert . . . . . . . . . . . .  in     ''
|     18 | convert                          in org.grails.datastore.mapping.model.types.conversion.DefaultConversionService
|    346 | cacheNativeEntry . . . . . . . . in org.grails.datastore.mapping.engine.NativeEntryEntityPersister
|    336 | createObjectFromNativeEntry      in     ''
|    886 | convertDBObject . . . . . . . .  in org.grails.datastore.mapping.mongo.query.MongoQuery$MongoResultList
|    898 | clone                            in     ''
|    507 | doInDB . . . . . . . . . . . . . in org.grails.datastore.mapping.mongo.query.MongoQuery$36
|    479 | doInDB                           in     ''
|    352 | execute . . . . . . . . . . . .  in org.springframework.data.mongodb.core.MongoTemplate
|    479 | executeQuery                     in org.grails.datastore.mapping.mongo.query.MongoQuery


Please Help me Out..

Thank you
Sagar Mane