-->
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.  [ 1 post ] 
Author Message
 Post subject: Table per subclass and lazy loading
PostPosted: Mon Feb 16, 2009 12:27 pm 
Newbie

Joined: Mon Feb 16, 2009 12:13 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.3.1.GA

Mapping documents:
Code:
<hibernate-mapping>
    <class name="it.blue.hibernate.beans.Richiesta" table="af_richiesta"  >
        <id name="codRich" column="codRich">
            <generator class="identity"/>
        </id>
        <discriminator column="richTipo" type="string"/>
      ...
      <many-to-one name="autore" class="it.blue.hibernate.beans.Utente" column="autore" cascade="merge" insert="true" />
      
      <subclass name="it.blue.hibernate.beans.RichInterne" discriminator-value="RICH_INTERNE"  >
        <join table="af_RichInterne" >
            <key column="codRich"  update="false"/>
            <property name="destRich"/>
        </join>
       </subclass>
      <subclass name="it.blue.hibernate.beans.RichIndagineAI" discriminator-value="RICH_INDAGINE_AI">
           <join table="af_RichIndagineAI" >
               <key column="codRich" update="false"/>
           </join>
       </subclass>
      <subclass name="it.blue.hibernate.beans.RichSegnRic" discriminator-value="RICH_SEGNALAZIONE" >
         <set name="istitutoDest" cascade="all">
            <key column="codRich" not-null="true" />
            <one-to-many class="it.blue.hibernate.beans.IstitutoDest" />
         </set>
         <join table="af_RichSegnRic">
               <key column="codRich" update="false"/>
               <property name="approfondimento"/>
           </join>
       </subclass>
   
    </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
JSF servlet with org.springframework.orm.hibernate3.support.OpenSessionInViewFilter

Hi Guys.
As you can see I've followed "Table per subclass, using a discriminator" pattern for my mapping class.
I have 2 table in my UI: first load only the RichIndagineAI records, with only the Richiesta variables. Here no problems.
The second one load RICH_SEGNALAZIONE records with Richiesta variables plus first element of istitutoDest collection.

here what hibernate write with lazy=true
Code:
02-16@17:08:30 DEBUG (  Loader.java:1197)     - result row: EntityKey[it.blue.hibernate.beans.Richiesta#75]
02-16@17:08:30 TRACE (NullableType.java:193)     - returning 'RICH_SEGNALAZIONE' as column: richTipo1_0_
02-16@17:08:30 TRACE (  Loader.java:1379)     - Initializing object from ResultSet: [it.blue.hibernate.beans.RichSegnRic#75]
02-16@17:08:30 TRACE (AbstractEntityPersister.java:2059)     - Hydrating entity: [it.blue.hibernate.beans.RichSegnRic#75]
02-16@17:08:30 TRACE (NullableType.java:193)     - returning '2009-01-20 13:31:52' as column: dataIns1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning '2009-01-30 01:00:00' as column: dataScad1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning '0' as column: criticita1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning '0' as column: urgenza1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning 'ok' as column: note1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning 'UL06781' as column: autore1_0_
02-16@17:08:30 TRACE (NullableType.java:193)     - returning 'true' as column: approfon2_4_0_
02-16@17:08:30 TRACE (  Loader.java:744)     - done processing result set (1 rows)
02-16@17:08:30 DEBUG (AbstractBatcher.java:433)     - about to close ResultSet (open ResultSets: 1, globally: 1)
02-16@17:08:30 DEBUG (AbstractBatcher.java:418)     - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
02-16@17:08:30 TRACE (AbstractBatcher.java:562)     - closing statement
02-16@17:08:30 TRACE (  Loader.java:874)     - total objects hydrated: 1
02-16@17:08:30 DEBUG (TwoPhaseLoad.java:130)     - resolving associations for [it.blue.hibernate.beans.RichSegnRic#75]
02-16@17:08:30 TRACE (LoadContexts.java:218)     - creating collection wrapper:[it.blue.hibernate.beans.Richiesta.docAllegati#75]
02-16@17:08:30 TRACE (LoadContexts.java:218)     - creating collection wrapper:[it.blue.hibernate.beans.Richiesta.noteAggiuntive#75]
02-16@17:08:30 TRACE (DefaultLoadEventListener.java:199)     - loading entity: [it.blue.hibernate.beans.Utente#UL06781]
02-16@17:08:30 TRACE (DefaultLoadEventListener.java:296)     - creating new proxy for entity
02-16@17:08:30 TRACE (LoadContexts.java:218)     - creating collection wrapper:[it.blue.hibernate.beans.RichSegnRic.istitutoDest#75]
02-16@17:08:30 DEBUG (TwoPhaseLoad.java:226)     - done materializing entity [it.blue.hibernate.beans.RichSegnRic#75]
02-16@17:08:30 DEBUG (StatefulPersistenceContext.java:860)     - initializing non-lazy collections



if I use lazy=false I'll get no error, but with lazy=true I'll get the following error.

Pls I really need help!!!


Full stack trace of any exception that occurs:
Code:
[16/02/09 17.08.30:147 CET] 00000030 ServletWrappe E   SRVE0068E: Impossibile richiamare il metodo service() per il servlet Blocking Servlet. Eccezione generata : javax.faces.el.PropertyNotFoundException: /facelets/column.jspx @48,57 value="${entityVar[output]}": Error getting property 'firstIstitute' from bean of type it.blue.hibernate.beans.Richiesta_$$_javassist_6
   at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
   at javax.faces.component.UIOutput.getValue(UIOutput.java:167)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicInputRenderer.getValue(DomBasicInputRenderer.java:60)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.getValue(DomBasicRenderer.java:154)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeEnd(DomBasicRenderer.java:126)
   at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:740)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:362)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358)
   at com.icesoft.faces.component.ext.renderkit.TableRenderer.encodeChildren(TableRenderer.java:758)
   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:721)
   at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:352)
   at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:92)
   at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:721)


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

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.