-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 
Author Message
 Post subject: Could not Query DB. could not initialize a collection
PostPosted: Thu Aug 27, 2009 3:09 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
I cannot figure out what i am doing wrong here - but for some reason i can't initialize my collection and my table can't be found.

Any help would be appreciated -thanks.



hibernate.cfg.xml:
Code:
       <class name="com.att.uma.hibernate.MyWorldChannelLineupData" table="TEST_MY_WORLD_LABELS">
           <id name="id">
         <generator class="sequence">              
             <param name="sequence">MY_WORLD_SEQ</param>
         </generator>
           </id>
       
           <map name="properties" lazy="false">
                  <key column="ID" />
         <index column="PROPERTY_NAME" type="string" />
                  <element column="PROPERTY_VALUE" type="string" />
           </map>
       </class>


DB Script:
Code:
CREATE TABLE TEST_MY_WORLD_LABELS
(
  PROPERTY_NAME   VARCHAR2(255 BYTE),
  PROPERTY_VALUE  VARCHAR2(255 BYTE),
  ID              INTEGER
)
TABLESPACE UMA_DAT
PCTUSED    0
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          128K
            NEXT             128K
            MINEXTENTS       1
            MAXEXTENTS       2147483645
            PCTINCREASE      0
            BUFFER_POOL      DEFAULT
           )
LOGGING
NOCACHE
NOPARALLEL
MONITORING;


Exception:
Code:
[8/27/09 14:05:41:478 CDT] 0000000a SystemOut     O 08/27/2009 14:05:41 WARN  util.JDBCExceptionReporter (Line:57) - SQL Error: 942, SQLState: 42000
[8/27/09 14:05:41:571 CDT] 0000000a SystemOut     O 08/27/2009 14:05:41 ERROR util.JDBCExceptionReporter (Line:58) - ORA-00942: table or view does not exist

[8/27/09 14:06:35:228 CDT] 0000000a SystemErr     R com.att.common.exception.HibernateQueryException: Could not Query DB. could not initialize a collection: [com.att.uma.hibernate.MyWorldChannelLineupData.properties#9]
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.att.common.hibernate.DBTransaction.query(DBTransaction.java:64)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.loadMappings(LoadMyWorldCachePlugin.java)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.init(LoadMyWorldCachePlugin.java:56)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at javax.servlet.GenericServlet.init(GenericServlet.java:256)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:310)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1696)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:140)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:820)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:547)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:419)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:117)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.VirtualHost.addWebApplication(VirtualHost.java:128)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.WebContainer.addWebApp(WebContainer.java:939)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:892)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:167)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:391)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1228)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1067)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:547)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:751)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:892)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2003)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ComponentImpl.runAsynchronousInitializer(ComponentImpl.java:159)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplications(ApplicationMgrImpl.java:745)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:524)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:149)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:408)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:187)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:133)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:387)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.runtime.WsServer.main(WsServer.java:53)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at java.lang.reflect.Method.invoke(Method.java:391)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at com.ibm.ws.bootstrap.WSLauncher.run(WSLauncher.java:219)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R    at java.lang.Thread.run(Thread.java:832)
[8/27/09 14:06:35:322 CDT] 0000000a SystemErr     R Caused by: org.hibernate.exception.SQLGrammarException: could not initialize a collection: [com.att.uma.hibernate.MyWorldChannelLineupData.properties#9]
   at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1374)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:105)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356)
   at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:271)
   at org.hibernate.engine.PersistenceContext.initializeNonLazyCollections(PersistenceContext.java:765)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:213)
   at org.hibernate.loader.Loader.doList(Loader.java:1522)
   at org.hibernate.loader.Loader.list(Loader.java:1505)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:400)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at com.att.common.hibernate.DBTransaction.query(DBTransaction.java:56)
   at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.loadMappings(LoadMyWorldCachePlugin.java)
   at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.init(LoadMyWorldCachePlugin.java:56)
   at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
   at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
   at javax.servlet.GenericServlet.init(GenericServlet.java:256)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:310)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1696)
   at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:140)
   at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:820)
   at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:547)
   at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:419)
   at com.ibm.ws.webcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:117)
   at com.ibm.ws.webcontainer.VirtualHost.addWebApplication(VirtualHost.java:128)
   at com.ibm.ws.webcontainer.WebContainer.addWebApp(WebContainer.java:939)
   at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:892)
   at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:167)
   at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:391)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1228)
   at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1067)
   at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:547)
   at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:751)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:892)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2003)
   at com.ibm.ws.runtime.component.ComponentImpl.runAsynchronousInitializer(ComponentImpl.java:159)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplications(ApplicationMgrImpl.java:745)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:524)
   at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
   at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
   at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:149)
   at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
   at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
   at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:408)
   at com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:187)
   at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:133)
   at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:387)
   at com.ibm.ws.runtime.WsServer.main(WsServer.java:53)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
   at java.lang.reflect.Method.invoke(Method.java:391)
   at com.ibm.ws.bootstrap.WSLauncher.run(WSLauncher.java:219)
   at java.lang.Thread.run(Thread.java:832)
Caused by: java.sql.SQLException: ORA-00942: table or view does not exist

   at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
   at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
   at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
   at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
   at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
   at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
   at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
   at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
   at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
   at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:527)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.pmiExecuteQuery(WSJdbcPreparedStatement.java:690)
   at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:488)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:118)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1204)
   at org.hibernate.loader.Loader.doQuery(Loader.java:368)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:208)
   at org.hibernate.loader.Loader.loadCollection(Loader.java:1367)
   at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:105)
   at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:488)
   at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
   at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1356)
   at org.hibernate.collection.AbstractPersistentCollection.forceInitialization(AbstractPersistentCollection.java:271)
   at org.hibernate.engine.PersistenceContext.initializeNonLazyCollections(PersistenceContext.java:765)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:213)
   at org.hibernate.loader.Loader.doList(Loader.java:1522)
   at org.hibernate.loader.Loader.list(Loader.java:1505)
   at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:400)
   at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:791)
   at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
   at com.att.common.hibernate.DBTransaction.query(DBTransaction.java:56)
   at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.loadMappings(LoadMyWorldCachePlugin.java)
   at com.att.uma.struts.plugins.LoadMyWorldCachePlugin.init(LoadMyWorldCachePlugin.java:56)
   at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:871)
   at org.apache.struts.action.ActionServlet.init(ActionServlet.java:359)
   at javax.servlet.GenericServlet.init(GenericServlet.java:256)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:310)
   at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1696)
   at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:140)
   at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:820)
   at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:547)
   at com.ibm.ws.webcontainer.webapp.WebApp.initialize(WebApp.java:419)
   at com.ibm.ws.webcontainer.webapp.WebGroup.addWebApplication(WebGroup.java:117)
   at com.ibm.ws.webcontainer.VirtualHost.addWebApplication(VirtualHost.java:128)
   at com.ibm.ws.webcontainer.WebContainer.addWebApp(WebContainer.java:939)
   at com.ibm.ws.webcontainer.WebContainer.addWebApplication(WebContainer.java:892)
   at com.ibm.ws.runtime.component.WebContainerImpl.install(WebContainerImpl.java:167)
   at com.ibm.ws.runtime.component.WebContainerImpl.start(WebContainerImpl.java:391)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1228)
   at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1067)
   at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:547)
   at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:751)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:892)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl$AppInitializer.run(ApplicationMgrImpl.java:2003)
   at com.ibm.ws.runtime.component.ComponentImpl.runAsynchronousInitializer(ComponentImpl.java:159)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplications(ApplicationMgrImpl.java:745)
   at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:524)
   at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
   at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
   at com.ibm.ws.runtime.component.ApplicationServerImpl.start(ApplicationServerImpl.java:149)
   at com.ibm.ws.runtime.component.ContainerImpl.startComponents(ContainerImpl.java:820)
   at com.ibm.ws.runtime.component.ContainerImpl.start(ContainerImpl.java:649)
   at com.ibm.ws.runtime.component.ServerImpl.start(ServerImpl.java:408)
   at com.ibm.ws.runtime.WsServerImpl.bootServerContainer(WsServerImpl.java:187)
   at com.ibm.ws.runtime.WsServerImpl.start(WsServerImpl.java:133)
   at com.ibm.ws.runtime.WsServerImpl.main(WsServerImpl.java:387)
   at com.ibm.ws.runtime.WsServer.main(WsServer.java:53)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:85)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:58)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:60)
   at java.lang.reflect.Method.invoke(Method.java:391)
   at com.ibm.ws.bootstrap.WSLauncher.run(WSLauncher.java:219)
   at java.lang.Thread.run(Thread.java:832)

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Thu Aug 27, 2009 3:26 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Forgot to send the POJO.

Code:
   /** identifier field */
   private int mId;

   /** persistent field */
   private Map mProperties;
   
   /** default constructor */
   public MyWorldChannelLineupData() {}   
    
   /**
    * Sets the properties.
    *
    * @param <code>Map</code>
    */   
   public void setProperties(Map m)
   {
      mProperties = m;
   }

   /**
    * Gets the properties.
    *
    * @return Map
    */   
   public Map getProperties()
   {
      return mProperties;
   }
   
   /**
    * Gets the id.
    *
    * @return String
    */
   public int getId()
   {
      return mId;
   }

   /**
    * Sets the id.
    *
    * @param <code>String</code>
    */
   public void setId(int id)
   {
      mId = id;
   }

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 11:26 am 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Hi,
i did not work with Map's but out of curiosity..
have you modified the hibernate config NOT to load the collection by default and does it find your table then?

<map name="properties" lazy="true">
<key column="ID" />
<index column="PROPERTY_NAME" type="string" />
<element column="PROPERTY_VALUE" type="string" />
</map>


use a HQL just to load instances of MyWorldChannelLineupData? can you just print the mId? does it fetch the data?

-Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 11:29 am 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Yes i did that - i removed the lazy attribute (default is true) and it did find my table - but i got the lazy initialization error - session was closed or something.

I was wanting to load the data up front - and not do a lazy initialization of the data.

Thanks

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 12:09 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Hi,
I don't know your requirement of having map of values pointing to the same table. Usually map or set of values point to the data from some other table and join by a primary/foreign key. So I guess Hibernate is trying to think of the table that I could point to and did not find any so throws out an error.
try this not sure if it works in a way this is self join?:-
<map name="properties" lazy="true" table="TEST_MY_WORLD_LABELS">
<key column="ID" />
<index column="PROPERTY_NAME" type="string" />
<element column="PROPERTY_VALUE" type="string" />
</map>

Please turn on the show_sql=true on the hibernate.properties file to see hibernate queries.
-Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 12:20 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Yeah i did that - and i got a foreign key does not match the number of columns in associated to the primary key.

I have the sql comments turned on.

Thanks

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 12:38 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
So what is your requirement? Can you post some data from the table TEST_MY_WORLD_LABELS? Also the current stack trace (adding table information to the map)?
Thanks,
-Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 12:47 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Our application provides content to client applications. We are supporting a new client application that want's to control all static content thru the DB (TeamSite Interwoven Interface). I was wanting to generically enable the table structure in a way that content managers could add/remove data from the table and our logic would not have to know about these changes. The Hibernate Collection Mapping seemed like a good option to go with. This would generically generate a map key/value pair that could be used on the presentation side of the house using JSTL.

I can get this to work just mapping each column and then creating my own map from those values. But i would like to get the Hibernate Collection Mapping working as well.

Thanks

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 1:23 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
So your table data looks like this:-
Option 1:-
Id PROPERTY_NAME PROPERTY_VALUE
1 test1 value1
1 test1 value2
2 test2 value1
2 test2 value2

and you want based on the ID map of keys as test1 and values of value1,value2??
OR
Option 2:-

Id PROPERTY_NAME PROPERTY_VALUE
1 test1 value1
2 test2 value1

you want the data for the sake of Presentation tier as Id, map(test1,value1) ??


If your requirement is Option 2 then you don't need to change the hibernate mapping. All you need is plain mapping file but in the HQL you can retrieve data as Id, map(test1,value1).

Hope this helps,
Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 1:31 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
I was wanting more along the lines of Option 1:

So mytable data looks like this:-
Option 1:-
Id PROPERTY_NAME PROPERTY_VALUE
1 test1 value1
1 test2 value2
2 test3 value3
2 test4 value4

map would look this:

map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

This way in the JSTL - i can just do something simple like this: ${map.test1}.

Thanks

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 1:32 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Sorry the ID field would be sequential as well. 1, 2, 3, 4.

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 1:47 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Sorry I don't understand this and may not be of any help.
for the requirement of
Option 1:-
Id PROPERTY_NAME PROPERTY_VALUE
1 test1 value1
2 test2 value2
3 test3 value3
4 test4 value4

you would like a map of all entries in the database for each Id?? I don't know if this can be achieved and desirable in the first place. There is no real Association to start with.
Id =1
map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

ID=2
map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

Sorry!
-Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 1:57 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
I guess i don't really need the ID column since i am not joining with another table - i actually got that from an example.

So instead of this:

Id PROPERTY_NAME PROPERTY_VALUE
Id =1
map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

ID=2
map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

I guess i would like to get this:

PROPERTY_NAME PROPERTY_VALUE

map
{
test1, value1,
test2, value2,
test3, value3,
test4, value4
}

Hope this makes some sense - sometimes things are hard to explain.

_________________
Thanks


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 3:08 pm 
Regular
Regular

Joined: Mon Jan 05, 2009 6:42 pm
Posts: 99
Location: IL
Ok.. I guess you need a plain Hibernate Mapping file. Keep the Id too.
in the HQL just like select PROPERTY_NAME,PROPERTY_VALUE from TEST_MY_WORLD_LABELS you could do:-

select new map(PROPERTY_NAME,PROPERTY_VALUE) from TEST_MY_WORLD_LABELS. The query would return List of <Map> objects.
OR
Just load the table into memory and you create a Map of data yourself
For example:- select ID, PROPERTY_NAME,PROPERTY_VALUE from TEST_MY_WORLD_LABELS would return List<MyWorldChannelLineupData> Instances and you can iterate through them to make a Map<String,String> of PROPERTY_NAME,PROPERTY_VALUE for you to just **test** this out, you don't even need a hibernate mapping. (Later on you would just a plain mapping file since you might want to insert/update/delete records).

Define your POJO
public class MyWorldChannelLineupData{
private int mId;
private String PROPERTY_NAME ;
private String PROPERTY_VALUE;
//corresponding getters and setters
..
}

Get Hibernate Session,
Session session =//get session;
List<MyWorldChannelLineupData> objs =session.createSQLQuery("select * from TEST_MY_WORLD_LABELS").setResultTransformer(Transformers.aliasToBean(MyWorldChannelLineupData.class)).list();

Iterate through the list and make a map of objects that you could return to the UI. This is the best way I can think of but wait for someone else to respond too and make a right decision.
Good Luck!
Srilatha.


Top
 Profile  
 
 Post subject: Re: Could not Query DB. could not initialize a collection
PostPosted: Fri Aug 28, 2009 3:43 pm 
Newbie

Joined: Wed Nov 12, 2008 12:16 pm
Posts: 15
Yeah - that was what i ended up doing to get this to work.

Thanks for you time and help!!

_________________
Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 15 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.