我正在使用play framework 2.3x 导入play.db.jpa.JPA我遇到问题;在我的Controller类Application.java中,或者不是jpa.em()也不在控制器类
中工作我的build.scala类是
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
javaWs,
"mysql" % "mysql-connector-java" % "5.1.18",
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
"org.hibernate" % "hibernate-entitymanager" % "4.3.9.Final",
"com.google.code.gson" % "gson" % "2.2"
)
我的conf / META-INF / 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="defaultPersistenceUnit" 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.MySQLInnoDBDialect"/>
</properties>
</persistence-unit>
</persistence>
我的模型类是
@javax.persistence.Entity
@Table(name = "customer")
public class Customer extends Model {
public static Finder<Integer, Customer> find = new Finder<Integer, Customer>(
Integer.class, Customer.class
);
@Id
@Column(name = "cid")
int cid;
@Column(name = "name")
public String name;
public int getCid() {
return cid;
}
public void setCid(int cid) {
this.cid = cid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static List<Customer> findAll() {
return find.all();
}
}