database - Need to understand the Logic of Playframework -


i have simple question. if use play.db.ebean.model have model extend model, how can save db? more clearly: in django, database file created , save object, saved db file , dont sql statements retrieving or saving objects.. how work in playframework?

lets have configured database file in application.conf file this:

db.default.driver=org.h2.driver db.default.url="jdbc:h2:tcp://localhost/~/microblogdb" db.default.user="sa" db.default.password="" 

now have database file somewhere in system.

now have class user extends model stated above. want save 1 user object db. this:

user user = new user(); user.username = "testusername"; user.fullname = "userfullname"; user.save(); 

what happen after save() call? can directly see user object in database file?

appreciate help!

many thanks

yes will, if didn't mistakes.

make sure in application.conf uncommented line:

ebean.default="models.*" 

check sample applications in sample folder of play package downloaded. example computerdatabase (not jpa version) see basics of working ebean.

what's more can create constructor(s) in model simplify creating user model:

public user(string username, string fullname) {     this.username = username;     this.fullname = fullname; } 

and use in controller as:

user user = new user("doniyor", "doniyor great"); user.save(); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -