javax.persistence.PersistenceException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Now that stored procedure tests have been added, I noticed that on 5.2.0 neither one of the REFCURSOR tests works anymore. To replicate it, first set up tests to run on PostgreSQL: {noformat} > gradle clean testClasses -Pdb=pgsql {noformat} Then run the {{org.hibernate.test.procedure.PostgreSQLStoredProcedureTest#testStoredProcedureOutParameter}} test. You'll get the following error: {noformat} javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:643) at org.hibernate.test.procedure.PostgreSQLStoredProcedureTest.testStoredProcedureOutParameter(PostgreSQLStoredProcedureTest.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) {noformat} Because the input parameters are doubled: {code:java} 13:28:46,836 DEBUG SQL:92 - {call sp_count_phones(?,?,?,?)} 13:28:46,838 TRACE BasicBinder:65 - binding parameter [1] as [BIGINT] - [1] 13:28:46,838 TRACE BasicBinder:65 - binding parameter [2] as [BIGINT] - [1] 13:28:46,844 WARN SqlExceptionHelper:129 - SQL Error: 0, SQLState: 42883 {code} Even if there were only two registrations: {code:java} StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_count_phones" ); query.registerStoredProcedureParameter( "personId", Long.class, ParameterMode.IN ); query.registerStoredProcedureParameter( "phoneCount", Long.class, ParameterMode.OUT ); query.setParameter( "personId", 1L ); query.execute(); Long phoneCount = (Long) query.getOutputParameterValue( "phoneCount" ); {code} Most likely, the issue comes from {{ProcedureCallImpl}} where in the {{registerStoredProcedureParameter}} method, the {{registerParameter}} method is called twice: {code:java} registerParameter( (ParameterRegistrationImplementor) registerParameter( parameterName, type, mode ) ); {code}
    via by Vlad Mihalcea,
  • Now that stored procedure tests have been added, I noticed that on 5.2.0 neither one of the REFCURSOR tests works anymore. To replicate it, first set up tests to run on PostgreSQL: {noformat} > gradle clean testClasses -Pdb=pgsql {noformat} Then run the {{org.hibernate.test.procedure.PostgreSQLStoredProcedureTest#testStoredProcedureOutParameter}} test. You'll get the following error: {noformat} javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Error calling CallableStatement.getMoreResults at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) at org.hibernate.procedure.internal.ProcedureCallImpl.execute(ProcedureCallImpl.java:643) at org.hibernate.test.procedure.PostgreSQLStoredProcedureTest.testStoredProcedureOutParameter(PostgreSQLStoredProcedureTest.java:184) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) {noformat} Because the input parameters are doubled: {code:java} 13:28:46,836 DEBUG SQL:92 - {call sp_count_phones(?,?,?,?)} 13:28:46,838 TRACE BasicBinder:65 - binding parameter [1] as [BIGINT] - [1] 13:28:46,838 TRACE BasicBinder:65 - binding parameter [2] as [BIGINT] - [1] 13:28:46,844 WARN SqlExceptionHelper:129 - SQL Error: 0, SQLState: 42883 {code} Even if there were only two registrations: {code:java} StoredProcedureQuery query = entityManager.createStoredProcedureQuery( "sp_count_phones" ); query.registerStoredProcedureParameter( "personId", Long.class, ParameterMode.IN ); query.registerStoredProcedureParameter( "phoneCount", Long.class, ParameterMode.OUT ); query.setParameter( "personId", 1L ); query.execute(); Long phoneCount = (Long) query.getOutputParameterValue( "phoneCount" ); {code} Most likely, the issue comes from {{ProcedureCallImpl}} where in the {{registerStoredProcedureParameter}} method, the {{registerParameter}} method is called twice: {code:java} registerParameter( (ParameterRegistrationImplementor) registerParameter( parameterName, type, mode ) ); {code}
    via by Vlad Mihalcea,
  • Spring Data error on Query after detach
    via Stack Overflow by Gavi
    ,
  • I want Hibernate to manage the order of a list. The time the list is generated, everything seems to work fine. The tables look like I would expect them to look, the items are retrieved in the order they have been saved. The problem occurs when reordering the item list (removing item and inserting it at another place in the same list). I get the following error (first two lines are test output from my program): {{MOVE CHILD DATA One / Two / Three / Four / Five / Hibernate: delete from ParentData_ChildData where ParentData_id=? and listOrder=? Hibernate: update ParentData_ChildData set children_id=? where ParentData_id=? and listOrder=? Mär 12, 2017 11:13:26 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions WARN: SQL Error: -104, SQLState: 23505 Mär 12, 2017 11:13:26 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions ERROR: integrity constraint violation: unique constraint or index violation; UK_9TWN3CBE7SO94343AOP2QKCTC table: PARENTDATA_CHILDDATA Mär 12, 2017 11:13:26 PM org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl release INFO: HHH000010: On release of batch it still contained JDBC statements javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1413) at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1393) at net.upf.hibtest.HibTest.main(HibTest.java:56)}} The third line indicates that hibernate tries to set a new children_id for an already existing listOrder position before removing this children_id at the previous listOrder postion and thus duplicationg this id. Tried two databases (MariaDB on server and local HSQLDB), both gave the same results. I set up a very basic testcase that can reproduce the behaviour. It consits of three files: parent-entity, child-entity and main()-method. I put my testcase in the attached zip, also containing the hibernate.cfg.xml. Hope this helps to reproduce the problem or see where I got something wrong. Additional info: I always want to go from parent to child, so I didn't put a reference to the parent into the child (which should be OK, according to some documentation I found) and I understand, that this might not be the fastest solution on earth - but it should at least work somehow. I kept this short and hope this bug report has all necessary information - for more explanation you also find my question here: https://forum.hibernate.org/viewtopic.php?f=1&t=1044101 I mark this as a blocker to me, since it simply blocks me from getting the task done. PS: Sorry for any confusion - I uploaded a second src.zip which should make it easier to use the hibernate.cfg.xml file. A also was testing around with the name of the OrderColumn and left the wrong name there in the first version. I can't delete it, so please just ignore the first src.zip
    via by Uwe,
    • javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute statement 19:42:54.374 [PMPUTestBot Telegram Executor] DEBUG org.hibernate.boot.registry.internal.BootstrapServiceRegistryImpl - Implicitly destroying Boot-strap registry on de-registration of all child ServiceRegistries at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155) at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162) at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1411) at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:475) at org.hibernate.internal.SessionImpl.flushBeforeTransactionCompletion(SessionImpl.java:3168) at org.hibernate.internal.SessionImpl.beforeTransactionCompletion(SessionImpl.java:2382) at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.beforeTransactionCompletion(JdbcCoordinatorImpl.java:467) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.beforeCompletionCallback(JdbcResourceLocalTransactionCoordinatorImpl.java:146) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl.access$100(JdbcResourceLocalTransactionCoordinatorImpl.java:38) at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.commit(JdbcResourceLocalTransactionCoordinatorImpl.java:220) at org.hibernate.engine.transaction.internal.TransactionImpl.commit(TransactionImpl.java:68) at dao.GroupDaoImpl.initGroup(GroupDaoImpl.java:32)

    Users with the same issue

    tvrmsmith
    1 times, last one,
    Pilleo
    4 times, last one,
    Unknown visitor1 times, last one,
    Unknown visitor1 times, last one,