MySQLIntegrityConstraintViolationException after upgrading Plat Framework 1.2.7 to 1.5.2












0














I needed to update my Play Framework 1 application because of Java and distribution updates on my servers.



After doing the necessary changes for JDK 1.8 everything seems to work. However, when inserting a new record I get the following error.



08:49:44,922 ERROR ~ Error during device update (Job): org.hibernate.exception.ConstraintViolationException: could not execute statement
javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1460)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)
at play.db.jpa.JPABase._save(JPABase.java:58)
at play.db.jpa.GenericModel.create(GenericModel.java:375)
at models.Device.createDevice(Device.java:154)
at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:104)
at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:1)
at play.jobs.Job$2.apply(Job.java:224)
at play.db.jpa.JPA.withTransaction(JPA.java:285)
at play.db.jpa.JPA.withinFilter(JPA.java:238)
at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:304)
at play.jobs.Job.withinFilter(Job.java:201)
at play.jobs.Job.call(Job.java:220)
at play.jobs.Job$1.call(Job.java:135)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3171)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3686)
at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:380)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)
... 19 more
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '215' for key 'PRIMARY'
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)
at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
... 27 more


MySQL tells me that the next index is 44806, which is what I expect.



I have two server, and when only running the old code (Play 1.2.7) it works fine and gives me an ID as expected. Both servers use the same database.



It is the new implementation that gives the low value (215 in the example below) so must not use the value in the database but something else.I did notice a table called hibernate_sequence with a 'next_val' field which does give a value close to the 215. It has 25 rows with that one column with all the same numbers.



Has something changed with the new Hibernate implementation so that I need to change something to use the 'Next autoindex' again?










share|improve this question



























    0














    I needed to update my Play Framework 1 application because of Java and distribution updates on my servers.



    After doing the necessary changes for JDK 1.8 everything seems to work. However, when inserting a new record I get the following error.



    08:49:44,922 ERROR ~ Error during device update (Job): org.hibernate.exception.ConstraintViolationException: could not execute statement
    javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
    at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1460)
    at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)
    at play.db.jpa.JPABase._save(JPABase.java:58)
    at play.db.jpa.GenericModel.create(GenericModel.java:375)
    at models.Device.createDevice(Device.java:154)
    at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:104)
    at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:1)
    at play.jobs.Job$2.apply(Job.java:224)
    at play.db.jpa.JPA.withTransaction(JPA.java:285)
    at play.db.jpa.JPA.withinFilter(JPA.java:238)
    at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:304)
    at play.jobs.Job.withinFilter(Job.java:201)
    at play.jobs.Job.call(Job.java:220)
    at play.jobs.Job$1.call(Job.java:135)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
    Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
    at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
    at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
    at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3171)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3686)
    at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
    at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
    at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:380)
    at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
    at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)
    ... 19 more
    Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '215' for key 'PRIMARY'
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    at com.mysql.jdbc.Util.getInstance(Util.java:408)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
    at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
    at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
    at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
    at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
    at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
    ... 27 more


    MySQL tells me that the next index is 44806, which is what I expect.



    I have two server, and when only running the old code (Play 1.2.7) it works fine and gives me an ID as expected. Both servers use the same database.



    It is the new implementation that gives the low value (215 in the example below) so must not use the value in the database but something else.I did notice a table called hibernate_sequence with a 'next_val' field which does give a value close to the 215. It has 25 rows with that one column with all the same numbers.



    Has something changed with the new Hibernate implementation so that I need to change something to use the 'Next autoindex' again?










    share|improve this question

























      0












      0








      0







      I needed to update my Play Framework 1 application because of Java and distribution updates on my servers.



      After doing the necessary changes for JDK 1.8 everything seems to work. However, when inserting a new record I get the following error.



      08:49:44,922 ERROR ~ Error during device update (Job): org.hibernate.exception.ConstraintViolationException: could not execute statement
      javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1460)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)
      at play.db.jpa.JPABase._save(JPABase.java:58)
      at play.db.jpa.GenericModel.create(GenericModel.java:375)
      at models.Device.createDevice(Device.java:154)
      at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:104)
      at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:1)
      at play.jobs.Job$2.apply(Job.java:224)
      at play.db.jpa.JPA.withTransaction(JPA.java:285)
      at play.db.jpa.JPA.withinFilter(JPA.java:238)
      at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:304)
      at play.jobs.Job.withinFilter(Job.java:201)
      at play.jobs.Job.call(Job.java:220)
      at play.jobs.Job$1.call(Job.java:135)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3171)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3686)
      at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:380)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)
      ... 19 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '215' for key 'PRIMARY'
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
      at com.mysql.jdbc.Util.getInstance(Util.java:408)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
      at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
      at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
      at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)
      at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
      at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
      ... 27 more


      MySQL tells me that the next index is 44806, which is what I expect.



      I have two server, and when only running the old code (Play 1.2.7) it works fine and gives me an ID as expected. Both servers use the same database.



      It is the new implementation that gives the low value (215 in the example below) so must not use the value in the database but something else.I did notice a table called hibernate_sequence with a 'next_val' field which does give a value close to the 215. It has 25 rows with that one column with all the same numbers.



      Has something changed with the new Hibernate implementation so that I need to change something to use the 'Next autoindex' again?










      share|improve this question













      I needed to update my Play Framework 1 application because of Java and distribution updates on my servers.



      After doing the necessary changes for JDK 1.8 everything seems to work. However, when inserting a new record I get the following error.



      08:49:44,922 ERROR ~ Error during device update (Job): org.hibernate.exception.ConstraintViolationException: could not execute statement
      javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:154)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:181)
      at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:188)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1460)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1440)
      at play.db.jpa.JPABase._save(JPABase.java:58)
      at play.db.jpa.GenericModel.create(GenericModel.java:375)
      at models.Device.createDevice(Device.java:154)
      at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:104)
      at logic.helpers.DevicePerformer.doJobWithResult(DevicePerformer.java:1)
      at play.jobs.Job$2.apply(Job.java:224)
      at play.db.jpa.JPA.withTransaction(JPA.java:285)
      at play.db.jpa.JPA.withinFilter(JPA.java:238)
      at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:304)
      at play.jobs.Job.withinFilter(Job.java:201)
      at play.jobs.Job.call(Job.java:220)
      at play.jobs.Job$1.call(Job.java:135)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
      Caused by: org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:59)
      at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
      at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3171)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3686)
      at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:90)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:478)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:380)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:39)
      at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1454)
      ... 19 more
      Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '215' for key 'PRIMARY'
      at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
      at com.mysql.jdbc.Util.getInstance(Util.java:408)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976)
      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912)
      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530)
      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2683)
      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2486)
      at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1858)
      at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2079)
      at com.mysql.jdbc.PreparedStatement.executeUpdateInternal(PreparedStatement.java:2013)
      at com.mysql.jdbc.PreparedStatement.executeLargeUpdate(PreparedStatement.java:5104)
      at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1998)
      at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
      at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
      at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
      ... 27 more


      MySQL tells me that the next index is 44806, which is what I expect.



      I have two server, and when only running the old code (Play 1.2.7) it works fine and gives me an ID as expected. Both servers use the same database.



      It is the new implementation that gives the low value (215 in the example below) so must not use the value in the database but something else.I did notice a table called hibernate_sequence with a 'next_val' field which does give a value close to the 215. It has 25 rows with that one column with all the same numbers.



      Has something changed with the new Hibernate implementation so that I need to change something to use the 'Next autoindex' again?







      mysql hibernate playframework






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 9:02









      Luuk D. JansenLuuk D. Jansen

      2,09753777




      2,09753777
























          1 Answer
          1






          active

          oldest

          votes


















          0














          The difference was that with Hibernate 5 not specifying the Generation strategy results in Hibernate using its own.



          Using the MySQL values can be done by the following annotation:



          @GeneratedValue(strategy = GenerationType.IDENTITY)





          share|improve this answer





















            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258796%2fmysqlintegrityconstraintviolationexception-after-upgrading-plat-framework-1-2-7%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The difference was that with Hibernate 5 not specifying the Generation strategy results in Hibernate using its own.



            Using the MySQL values can be done by the following annotation:



            @GeneratedValue(strategy = GenerationType.IDENTITY)





            share|improve this answer


























              0














              The difference was that with Hibernate 5 not specifying the Generation strategy results in Hibernate using its own.



              Using the MySQL values can be done by the following annotation:



              @GeneratedValue(strategy = GenerationType.IDENTITY)





              share|improve this answer
























                0












                0








                0






                The difference was that with Hibernate 5 not specifying the Generation strategy results in Hibernate using its own.



                Using the MySQL values can be done by the following annotation:



                @GeneratedValue(strategy = GenerationType.IDENTITY)





                share|improve this answer












                The difference was that with Hibernate 5 not specifying the Generation strategy results in Hibernate using its own.



                Using the MySQL values can be done by the following annotation:



                @GeneratedValue(strategy = GenerationType.IDENTITY)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 '18 at 19:12









                Luuk D. JansenLuuk D. Jansen

                2,09753777




                2,09753777






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53258796%2fmysqlintegrityconstraintviolationexception-after-upgrading-plat-framework-1-2-7%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Coverage of Google Street View

                    Full-time equivalent

                    Surfing