org.hibernate.exception.SQLGrammarException: could not extract ResultSet

Hibernate JIRA | Richard Barnes | 4 months ago
  1. 0

    We have an entity class Product with InheritanceType.JOINED. This has a field inventoryCode. We have an entity subclass Book extends Product. We have an entity class Library. There is a OneToMany from Library to Book: {code} @OneToMany(mappedBy="library") @MapKey(name="inventoryCode") private Map<String,Book> booksOnInventory = new HashMap<String,Book>(); {code} and a back-link from Book to Library {code} @ManyToOne private Library library; {code} Operations trying to access this Map at runtime (Map.size(), entrySet(), etc) fall over with an SQLGrammarException because MapBinder is trying to look for the column inventoryCode on the table for Book rather than on the joined table for the superclass (example stack trace below). As might be imagined, this only happens for the JOINED inheritance type. I have a test case which I will attach shortly. {quote} ERROR: Unknown column 'booksoninv0_.INVCODE' in 'field list' org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.getResultSet(AbstractLoadPlanBasedLoader.java:434) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:186) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121) at org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86) at org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:87) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682) at org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75) at org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2142) at org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:567) at org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:249) at org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:563) {quote}

    Hibernate JIRA | 4 months ago | Richard Barnes
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  2. 0

    JPA and Hibernate initialize Non Lazy Collections Error

    Stack Overflow | 3 years ago | Channa
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  3. 0

    An unknown target entity property error

    Stack Overflow | 2 years ago | Miguel Bestia
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    How to retrieve records of bidirectional relationship?

    Stack Overflow | 3 years ago | J888
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet
  6. 0

    How invoke a Store Procedure using Hibernate con Sql Server 2000?

    Stack Overflow | 2 years ago | Hernando
    org.hibernate.exception.SQLGrammarException: could not extract ResultSet

  1. Kawada 3 times, last 7 months ago
1 unregistered visitors
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.exception.SQLGrammarException

    could not extract ResultSet

    at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert()
  2. Hibernate
    ResultSetReturnImpl.extract
    1. org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
    2. org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
    3. org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
    4. org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
    5. org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
    5 frames
  3. org.hibernate.loader
    AbstractLoadPlanBasedCollectionInitializer.initialize
    1. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.getResultSet(AbstractLoadPlanBasedLoader.java:434)
    2. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeQueryStatement(AbstractLoadPlanBasedLoader.java:186)
    3. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:121)
    4. org.hibernate.loader.plan.exec.internal.AbstractLoadPlanBasedLoader.executeLoad(AbstractLoadPlanBasedLoader.java:86)
    5. org.hibernate.loader.collection.plan.AbstractLoadPlanBasedCollectionInitializer.initialize(AbstractLoadPlanBasedCollectionInitializer.java:87)
    5 frames
  4. Hibernate
    AbstractPersistentCollection.initialize
    1. org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:682)
    2. org.hibernate.event.internal.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:75)
    3. org.hibernate.internal.SessionImpl.initializeCollection(SessionImpl.java:2142)
    4. org.hibernate.collection.internal.AbstractPersistentCollection$4.doWork(AbstractPersistentCollection.java:567)
    5. org.hibernate.collection.internal.AbstractPersistentCollection.withTemporarySessionIfNeeded(AbstractPersistentCollection.java:249)
    6. org.hibernate.collection.internal.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:563)
    6 frames