grails - Missing table in database -


hello have domain class user , created myself controller register people.when run project , enter fields , press enter error by:

org.springframework.jdbc.badsqlgrammarexception: hibernate operation: not extract resultset; bad sql grammar [n/a]; nested exception org.postgresql.util.psqlexception: error: column this_.id not exist 

i connected postgresql .i have other domain classes have own table in database, domain class doesn't have think reason error,how can fix it?

    class user {     string login     string password     string name       static constraints = {       login size: 3..20 , unique: true, nullable: false         password size: 3..20, unique: false, nullable: false         name size: 3..20, unique: false, nullable: false     }  }      class usercontroller {     def scaffold = user     def login = {}     def authenticate = {         def user = user.findbyloginandpassword(params.login, params.password)         if(user){             session.user = user             flash.message = "hello ${user.name}!"             redirect(controller:"entry", action:"list")         }else{             flash.message = "sorry, ${params.login}. please try again."             redirect(action:"login")         }     }      def logout = {         flash.message = "goodbye ${session.user.name}"         session.user = null         redirect(controller:"entry", action:"list")     } }  class registerusercontroller { def index() { } def register(string user,string password,string name) {        def user2=new user(login: user,password : password,name: name)         if (user2.validate() && user2.save() )  {             redirect(url: "http://localhost:8080")         } else {         }     } } 

i error on : if (user2.validate() && user2.save() )

the application.yml file:

hibernate: cache:     queries: false     use_second_level_cache: true     use_query_cache: false     region.factory_class: org.hibernate.cache.ehcache.singletonehcacheregionfactory   datasource: pooled: true jmxexport: true driverclassname: org.postgresql.driver username: postgres password:     environments: development:     datasource:         dbcreate: create-drop         url: jdbc:postgresql://localhost:5432/new         username: postgres         password: test:     datasource:         dbcreate: update         url: jdbc:postgresql://localhost:5432/new         username: postgres         password: production:     datasource:         dbcreate: update         url: jdbc:postgresql://localhost:5432/new         username: postgres         password: 

there no need call validate() because save() calls it.

try

 if (user2.save(flush:true, failonerror: true) )  {                 redirect(url: "http://localhost:8080")     } 

with failonerror can more sure error.

also if doesn't try change class name "user" else ex. "myuser" had faced issue in postgresql , changing class name resolved if don't remember wrong..


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -