java - Models not being saved in Play Framework -


assume model named user:

@entity public class user extends model {     @id     @constraints.min(10)     public long id;      @constraints.required     public string username;      @constraints.required     public string password;      public static finder<long, user> find = new finder<long, user>(         long.class, user.class     ); } 

when attempt update instance of user in controller:

    user user = user.find.where().eq("username", username).findunique();      if(user != null) {         user.username = "some_new_username";         user.save();     } 

no changes seem committed. read somewhere when alter model instance property, not dirty , therefore no changes take place. hence should use setter instead. in documentation of play framework said setters (and getters) generated automatically, using user.setusername(username) gives me compilation error:

cannot find symbol [symbol: method setusername(java.lang.string)] [location: class models.user] 

am missing something?

have tried adding custom setters?

@entity public class user extends model {     @id     @constraints.min(10)     public long id;      @constraints.required     public string username;      public void setusername(string _username) {         username = _username;     }      @constraints.required     public string password;      public void setpassword(string _password) {         password = _password;     }      public static finder<long, user> find = new finder<long, user>(         long.class, user.class     ); } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -