org.hibernate.AssertionFailure: cannot supply object to query loader

Hibernate JIRA | Bob Robertson | 1 decade ago
  1. 0

    we're using stored procedures for loading and saving: <hibernate-mapping default-access="field" default-lazy="false"> <!-- dummy values used as I don't want to specify the mapping - the stored procs take care of that --> <class name="LookupValue" table="dummy"> <id name="id" column="dummy1"/> <property name="text" column="dummy2"/> <property name="sourceType" column="dummy3"/> <loader query-ref="load-lookup"/> <sql-insert callable="true">{call insert(?, ?, ?)}</sql-insert> </class> <sql-query name="load-lookup" callable="true"> <return alias="" class="LookupValue"> <return-property name="id" column="id"/> <return-property name="text" column="text"/> <return-property name="sourceType" column="source"/> </return> {? = call bag(?) } </sql-query> </hibernate-mapping> Then in my DAO (using spring), inside a single transaction: Session session = getSession(false); LookupValue v = new LookupValue(0, "textValue", "sourceValue"); session.save(v); session.flush(); // want to get the value of the PK that the DB assigned for me, also more columns through triggers in the future session.refresh(v); But, during the call to refresh(). 15:42:49.360 ERROR [AssertionFailure]- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) org.hibernate.AssertionFailure: cannot supply object to query loader at org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:37) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471) at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:104) at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:679) at com.VariableHibernateDao.loadLookup(VariableHibernateDao.java:247) at com.SortedDataServiceImpl.fetchData(SortedDataServiceImpl.java:48) at com.TestVariableHibernateProcsDao.testGetILookup(TestVariableHibernateProcsDao.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    Hibernate JIRA | 1 decade ago | Bob Robertson
    org.hibernate.AssertionFailure: cannot supply object to query loader
  2. 0

    we're using stored procedures for loading and saving: <hibernate-mapping default-access="field" default-lazy="false"> <!-- dummy values used as I don't want to specify the mapping - the stored procs take care of that --> <class name="LookupValue" table="dummy"> <id name="id" column="dummy1"/> <property name="text" column="dummy2"/> <property name="sourceType" column="dummy3"/> <loader query-ref="load-lookup"/> <sql-insert callable="true">{call insert(?, ?, ?)}</sql-insert> </class> <sql-query name="load-lookup" callable="true"> <return alias="" class="LookupValue"> <return-property name="id" column="id"/> <return-property name="text" column="text"/> <return-property name="sourceType" column="source"/> </return> {? = call bag(?) } </sql-query> </hibernate-mapping> Then in my DAO (using spring), inside a single transaction: Session session = getSession(false); LookupValue v = new LookupValue(0, "textValue", "sourceValue"); session.save(v); session.flush(); // want to get the value of the PK that the DB assigned for me, also more columns through triggers in the future session.refresh(v); But, during the call to refresh(). 15:42:49.360 ERROR [AssertionFailure]- an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session) org.hibernate.AssertionFailure: cannot supply object to query loader at org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:37) at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471) at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:104) at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:679) at com.VariableHibernateDao.loadLookup(VariableHibernateDao.java:247) at com.SortedDataServiceImpl.fetchData(SortedDataServiceImpl.java:48) at com.TestVariableHibernateProcsDao.testGetILookup(TestVariableHibernateProcsDao.java:84) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

    Hibernate JIRA | 1 decade ago | Bob Robertson
    org.hibernate.AssertionFailure: cannot supply object to query loader
  3. 0

    java.sql.SQLException: You can't operate on a closed Statement!!!

    Oracle Community | 9 years ago | raysefo
    org.hibernate.AssertionFailure: possible non-threadsafe access to the session
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Hibernate Community • View topic - java.sql.SQLException: You can't operate on a closed Stateme

    hibernate.org | 5 months ago
    org.hibernate.AssertionFailure: possible non-threadsafe access to the session
  6. 0

    Spring Boot IllegalStateException ArchiveDescriptor reused; can URLs be processed multiple times?

    Stack Overflow | 2 years ago | mangusbrother
    java.lang.RuntimeException: error trying to scan <jar-file>: file:/C:/dev/trees/ix-platform/FakesSpringBoot/providers/providers/fake/app/targ et/__fake.jar

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. org.hibernate.AssertionFailure

      cannot supply object to query loader

      at org.hibernate.persister.entity.NamedQueryLoader.load()
    2. Hibernate
      BasicEntityPersister.load
      1. org.hibernate.persister.entity.NamedQueryLoader.load(NamedQueryLoader.java:37)
      2. org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
      2 frames
    3. Hibernate
      SessionImpl.refresh
      1. org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:104)
      2. org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:679)
      2 frames
    4. finagle-core
      TestVariableHibernateProcsDao.testGetILookup
      1. com.VariableHibernateDao.loadLookup(VariableHibernateDao.java:247)
      2. com.SortedDataServiceImpl.fetchData(SortedDataServiceImpl.java:48)
      3. com.TestVariableHibernateProcsDao.testGetILookup(TestVariableHibernateProcsDao.java:84)
      3 frames
    5. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    6. JUnit
      TestSuite.run
      1. junit.framework.TestCase.runTest(TestCase.java:154)
      2. junit.framework.TestCase.runBare(TestCase.java:127)
      3. junit.framework.TestResult$1.protect(TestResult.java:106)
      4. junit.framework.TestResult.runProtected(TestResult.java:124)
      5. junit.framework.TestResult.run(TestResult.java:109)
      6. junit.framework.TestCase.run(TestCase.java:118)
      7. junit.framework.TestSuite.runTest(TestSuite.java:208)
      8. junit.framework.TestSuite.run(TestSuite.java:203)
      8 frames
    7. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      3 frames