0

I have project in Play 2.1.5 and I've decided to migrate to Play 2.2.1. I followed http://www.playframework.com/documentation/2.2.1/Migration22 and everything works except that on startup it looks like the project is trying to create DB instead updating it. I always get duplicity errors. I didn't have this problem while I was using Play 2.1.5. I don't see any problem in my configuration, but maybe I overlooked something:

application.conf:

db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
db.default.url="jdbc:mysql://localhost/database"
db.default.driver=com.mysql.jdbc.Driver

persistence.xml:

<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.MySQLDialect"/>
        <property name="hibernate.format_sql" value="true"/>
        <property name="hibernate.hbm2ddl.auto" value="update"/>
    </properties>
</persistence-unit>

Build.scala dependencies contain:

javaCore,
javaJdbc,
javaJpa,
cache,
"org.hibernate" % "hibernate-entitymanager" % "4.2.7.Final"
user2545521
  • 63
  • 1
  • 9
  • When you running the project can you see any `create/drop` sql on console? – Amogh Jan 13 '14 at 14:10
  • do you have a play_evolutions table in your db? – Peter Jan 13 '14 at 14:12
  • There is no play_evolutions table. And when I run the app the console give me only errors like : **com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry 'VALUE' for key 'COLUMN_NAME'** after loading the configs. The application itself runs, but it's not acceptable to have these errors at startup – user2545521 Jan 13 '14 at 14:18

1 Answers1

0

With

<property name="hibernate.hbm2ddl.auto" value="update"/>

you are telling to update your schema according to your models each time you start the application. If you won't modify the schema try to set the value to validate. BTW Duplicate entry 'VALUE' for key 'COLUMN_NAME' error suggest you are trying to make some insert/update at start time, aren't you?

FrancescoM
  • 1,400
  • 11
  • 16