playframework - how to retrive data from db using hibernate , jpa -


i using play-2.1.3 framework. want retrive data db. using eclipse ,hibernate, , postgresql.

when want retrive data db entity mgr, gives me error, not find answer... please me.

----------------------error in log file--------------------------

2013-10-06 19:08:53,729 - [error] - org.hibernate.engine.jdbc.spi.sqlexceptionhelper in play-akka.actor.default-dispatcher-3  error: column client0_._ebean_intercept not exists   position: 31 

my entity class:

package models; import play.db.ebean.*; import play.data.validation.*; import javax.persistence.*; @entity @table(name="clients") public class client extends model {       /**      *       */     private static final long serialversionuid = 1l;      @id     @constraints.min(10)     public long id;    @constraints.required   public string username;    @constraints.required   public string email;    @constraints.required   public string password;    @constraints.required   public string passwordsignup_confirm;    public boolean online;     public boolean getonline() {         return online;     }      public void setonline(boolean online) {         this.online = online;     }      public string getusername() {         return username;     }      public void setusername(string username) {         this.username = username;     }      public string getemail() {         return email;     }      public void setemail(string email) {         this.email = email;     }      public string getpassword() {         return password;     }      public void setpassword(string password) {         this.password = password;     }      public string getconfirm() {         return passwordsignup_confirm;     }      public void setconfirm(string confirm) {         this.passwordsignup_confirm= confirm;     }    } 

------------------------------in controller class---------

public static client ckeckemailandpassword(string email, string password)     {         client client = null;         em.gettransaction().begin();              try             {                 list<client> cli = em.createquery("select d client d d.email = ?1 , d.password = ?2").setparameter(1, email).setparameter(2, password).getresultlist();                  em.gettransaction().commit();              }catch(exception e){                 e.printstacktrace();             }             return client;      } 

--------------------------------------build.scala

import sbt._ import keys._ import play.project._  object applicationbuild extends build {    val appname         = "unity"   val appversion      = "1.0-snapshot"    val appdependencies = seq(     // add project dependencies here,      javacore,     javajdbc,     javaebean,     "org.hibernate" % "hibernate-entitymanager" % "4.2.5.final"   )    val main = play.project(appname, appversion, appdependencies).settings(       ebeanenabled := false         )      } 

------------------------------------------persistence.xml

<?xml version="1.0" encoding="utf-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence"              xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"              xsi:schemalocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"              version="2.0">      <persistence-unit name="manager" transaction-type="resource_local">         <provider>org.hibernate.ejb.hibernatepersistence</provider>         <non-jta-data-source>defaultds</non-jta-data-source>          <properties>             <property name="hibernate.dialect" value="org.hibernate.dialect.h2dialect"/>         </properties>     </persistence-unit>   </persistence> 

-------------------------------------------------application.conf

 db.default.driver=org.postgresql.driver  db.default.url="jdbc:postgresql:postgres"  db.default.user=postgres  db.default.password="root"   db.default.jndiname=defaultds 

you have use config file(application.conf) db.

enter code here # database configuration # ~~~~~  db.default.driver=org.postgresql.driver db.default.url="jdbc:postgresql://localhost:5432/nameof_you_db" db.default.user=your_user_name db.default.password=you_password 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -