org.hibernate.exception.SQLGrammarException: could not initialize a collection: \[org.openxava.test.model.Customer.states\#4\]

openxava | hjatmbn | 1 decade ago
  1. 0

    OX2.0; OpenXavaTest; CustomerWithSections

    openxava | 1 decade ago | hjatmbn
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: \[org.openxava.test.model.Customer.states\#4\]
  2. 0

    org.hibernate.exception.SQLGrammarException: could not initialize a collection:[com.app.core.Users.processDetatilses#12]

    Stack Overflow | 2 years ago | Shubhankar
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.app.core.Users.processDetatilses#12]
  3. 0

    jtrac issues w/ UNIX and ORACLE

    j-trac | 8 years ago | hkansal
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: \[info.jtrac.domain.Item.history\#313\]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    The following test: public void test2(){ List<Storage> storages= getSF().openSession().createCriteria(Storage.class).list(); System.out.println("Storages:"); for(Storage storage:storages){ System.out.println(" - "+storage); Map<Product,Quantity> products=storage.getProductQuantity(); for(Product p:products.keySet()) System.out.println(" - - "+p+" "+products.get(p)); } @Entity @AccessType("field") public class Storage{ @Id protected int id; protected String name; @MapKey @OneToMany(cascade=CascadeType.ALL) protected Map<Product,Quantity> productQuantity=new HashMap<Product,Quantity>(); public Map<Product, Quantity> getProductQuantity(){ return productQuantity; } public void addProduct(Product product,Quantity quantity){ productQuantity.put(product,quantity); } Storage(){ } public Storage(String name){ this.name=name; id=hashCode(); } public String toString(){ return name; } } this class (Storage.class) persists perfectly (checked thru pgAdmin III), the name field is fetched, but when trying to fetch Map: for(Product p:products.keySet()) it fails with that kind of listing: Storages: - Main storage 12:04:36,154 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 42703 12:04:36,154 ERROR JDBCExceptionReporter:72 - ERROR: column productqua0_.id does not exist Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Storage.productQuantity#779317485] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.loadCollection(Loader.java:1926) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1693) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentMap.keySet(PersistentMap.java:190) at PTest.listStorage(Ptest.java:87) at PTest..test2(Ptest.java:80) at Ptest.<init>(Ptest.java:20) at Ptest.main(Ptest.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86) Caused by: org.postgresql.util.PSQLException: ERROR: column productqua0_.id does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1501) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1286) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:177) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139) at org.hibernate.loader.Loader.getResultSet(Loader.java:1669) at org.hibernate.loader.Loader.doQuery(Loader.java:662) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadCollection(Loader.java:1919) ... 16 more PS I've set priority to Critical, since it's really critical for me. It would be hard to write all the code now with Sets, which work fine, but the data structure is really ugly, and later refactor everything to Maps

    Hibernate JIRA | 1 decade ago | Philipp Pirozhkov
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Storage.productQuantity#779317485]
  6. 0

    The following test: public void test2(){ List<Storage> storages= getSF().openSession().createCriteria(Storage.class).list(); System.out.println("Storages:"); for(Storage storage:storages){ System.out.println(" - "+storage); Map<Product,Quantity> products=storage.getProductQuantity(); for(Product p:products.keySet()) System.out.println(" - - "+p+" "+products.get(p)); } @Entity @AccessType("field") public class Storage{ @Id protected int id; protected String name; @MapKey @OneToMany(cascade=CascadeType.ALL) protected Map<Product,Quantity> productQuantity=new HashMap<Product,Quantity>(); public Map<Product, Quantity> getProductQuantity(){ return productQuantity; } public void addProduct(Product product,Quantity quantity){ productQuantity.put(product,quantity); } Storage(){ } public Storage(String name){ this.name=name; id=hashCode(); } public String toString(){ return name; } } this class (Storage.class) persists perfectly (checked thru pgAdmin III), the name field is fetched, but when trying to fetch Map: for(Product p:products.keySet()) it fails with that kind of listing: Storages: - Main storage 12:04:36,154 WARN JDBCExceptionReporter:71 - SQL Error: 0, SQLState: 42703 12:04:36,154 ERROR JDBCExceptionReporter:72 - ERROR: column productqua0_.id does not exist Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Storage.productQuantity#779317485] at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.loader.Loader.loadCollection(Loader.java:1926) at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:71) at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520) at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60) at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1693) at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344) at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86) at org.hibernate.collection.PersistentMap.keySet(PersistentMap.java:190) at PTest.listStorage(Ptest.java:87) at PTest..test2(Ptest.java:80) at Ptest.<init>(Ptest.java:20) at Ptest.main(Ptest.java:13) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:86) Caused by: org.postgresql.util.PSQLException: ERROR: column productqua0_.id does not exist at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1501) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1286) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:177) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:430) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:346) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:250) at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:139) at org.hibernate.loader.Loader.getResultSet(Loader.java:1669) at org.hibernate.loader.Loader.doQuery(Loader.java:662) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224) at org.hibernate.loader.Loader.loadCollection(Loader.java:1919) ... 16 more PS I've set priority to Critical, since it's really critical for me. It would be hard to write all the code now with Sets, which work fine, but the data structure is really ugly, and later refactor everything to Maps

    Hibernate JIRA | 1 decade ago | Philipp Pirozhkov
    org.hibernate.exception.SQLGrammarException: could not initialize a collection: [Storage.productQuantity#779317485]

    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 initialize a collection: \[org.openxava.test.model.Customer.states\#4\]

      at org.hibernate.exception.SQLStateConverter.convert()
    2. Hibernate
      AbstractCollectionPersister.initialize
      1. org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
      2. org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      3. org.hibernate.loader.Loader.loadCollection(Loader.java:1926)
      4. org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
      5. org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:520)
      5 frames
    3. Hibernate
      PersistentSet.iterator
      1. org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
      2. org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1676)
      3. org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
      4. org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
      5. org.hibernate.collection.PersistentSet.iterator(PersistentSet.java:138)
      5 frames
    4. Java RT
      Collections.enumeration
      1. java.util.Collections$1.<init>(Collections.java:3369)
      2. java.util.Collections.enumeration(Collections.java:3368)
      2 frames
    5. org.openxava.model
      MapFacade.getValues
      1. org.openxava.model.impl.MapFacadeBean.getCollectionValues(MapFacadeBean.java:842)
      2. org.openxava.model.impl.MapFacadeBean.getCollectionValues(MapFacadeBean.java:823)
      3. org.openxava.model.impl.MapFacadeBean.getValues(MapFacadeBean.java:693)
      4. org.openxava.model.impl.MapFacadeBean.getValuesImpl(MapFacadeBean.java:489)
      5. org.openxava.model.impl.MapFacadeBean.getValues(MapFacadeBean.java:72)
      6. org.openxava.model.MapFacade.getValues(MapFacade.java:266)
      6 frames
    6. org.openxava.view
      View.getCollectionValues
      1. org.openxava.view.View.getCollectionValues(View.java:900)
      1 frame