November 19, 2013

JPA configuration for play framework

2  comments

In my current play project we decided to use hibernate as JPA implementation. Here is the configuration we use:

Dependencies in project/Build.scala

  val appDependencies = Seq(
    javaCore,
    javaJdbc,
    javaJpa,
    "org.hibernate" % "hibernate-entitymanager" % "4.2.7.Final"
  )

Database configuration in conf/application.conf

# Database configuration
# ~~~~~
db.default.driver=org.h2.Driver
db.default.url="jdbc:h2:file:data/db"
db.default.user=sa
db.default.password=""
db.default.jndiName=DefaultDS

jpa.default=defaultPersistenceUnit

Persistence unit in conf/META-INF/persistence.xml



    
        org.hibernate.ejb.HibernatePersistence
        DefaultDS
        
            
            
            
            
            
        
    


Tags

Hibernate, Java, JPA, Play Framework, Play Framework 2.2, Play4JPA, Scala


You may also like

Blog url changed to https

I just changed the url of this blog to https://jensjaeger.com. TLS encryption is now the default for all request to this page. It might be possible that some image links on some articles are hard coded http. If you find such an error it would be nice if you leave me comment so i can

Read More

Format date and time in java with prettytime

Prettytime is a nice java library to format a java Date()s in a nice humanized ago format, like: moments ago 2 minutes ago 13 hours ago 7 months ago 2 years ago Prettytime is localized in over 30 languages. It’s super simple to use Add the dependency to your maven pom: org.ocpsoft.prettytime prettytime 3.2.7.Final or

Read More