Skip to content

Spring JPA with Play!

peterszatmary edited this page Feb 21, 2016 · 4 revisions

Spring + JPA with Play!

application.conf

db.default.jndiName="someJndiName"
jpa.default="someJpaName"

persistence.xml

<non-jta-data-source>someJndiName</non-jta-data-source>
<persistence-unit name="someJpaName" transaction-type="RESOURCE_LOCAL">

build.sbt

libraryDependencies ++= Seq(
  javaCore,
  javaJpa,
  "org.springframework" % "spring-context" % "4.1.6.RELEASE",
  "javax.inject" % "javax.inject" % "1",
  "org.springframework.data" % "spring-data-jpa" % "1.3.2.RELEASE",
  "org.springframework" % "spring-expression" % "4.1.6.RELEASE",
  "mysql" % "mysql-connector-java" % "5.1.18",

application.conf

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/test"
db.default.user=root
db.default.pass="anarchitekt"
db.default.jndiName=DefaultDS

jpa.default=defaultPersistenceUnit

logger.play=INFO
logger.org.springframework=TRACE

persistence.xml

  <persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <non-jta-data-source>DefaultDS</non-jta-data-source>
    <properties>
      <!-- dialect for a MYSQL database -->
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect"/>
      <property name="hibernate.hbm2ddl.auto" value="update"/>
      <property name="hibernate.show_sql" value="true"/>
      <property name="hibernate.format_sql" value="true"/>
    </properties>