-->
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.  [ 2 posts ] 
Author Message
 Post subject: Lazy collection loading does not work for EntityMode.DOM4J
PostPosted: Mon May 11, 2009 11:51 am 
Newbie

Joined: Tue Mar 25, 2008 12:39 pm
Posts: 2
Hello,

I am using the following mapping:
Code:
<hibernate-mapping>

   <class entity-name="BlankEntity">
      <id name="id_" type="long">
         <generator class="native"/>
      </id>
   </class>

   <joined-subclass entity-name="up_CardInformation" extends="BlankEntity">
      <key column="up_CardInformation_id_"/>
      <list name="up_cardUsage">
         <key column="up_CardInformation_id"/>
         <list-index column="LIST_INDEX"/>
         <one-to-many class="up_CardUsage"/>
      </list>
   </joined-subclass>

   <joined-subclass entity-name="up_CardUsage" extends="BlankEntity">
      <key column="up_CardUsage_id_"/>
      <property name="up_cuSite" type="string"/>
   </joined-subclass>

</hibernate-mapping>




I am using DOM4J entity mode. When I load "up_CardInformation" entity, Hibernate (3.2.5) also loads "up_cardUsage" collection regardles of default lazy mode. I tried to set lazy attribute = "true" for "up_cardUsage" list, but it does not help. From the other hand, lazy collection loading works fine, if I switch entity mode to MAP.

I found out, that org.hibernate.type.CollectionType.getCollection(Serializable, SessionImplementor, Object) method ignores lazy collection loading mode, because of initializeImmediately(EntityMode) method:
Code:
   protected boolean initializeImmediately(EntityMode entityMode) {
      return entityMode == EntityMode.DOM4J;
   }


1. As I understand, there is no any way to use lazy loading for DOM4J entity mode. Am I correct?

2. Using DOM4J entity mode, I found some other bugs/problems like https://forum.hibernate.org/viewtopic.php?f=1&t=957391, impossibility of using null values. Does MAP entity mode free of such critical bugs?


Top
 Profile  
 
 Post subject: Re: Lazy collection loading does not work for EntityMode.DOM4J
PostPosted: Mon Jun 01, 2009 7:58 pm 
Newbie

Joined: Mon Jun 01, 2009 7:39 pm
Posts: 1
I agree, it would be useful to be able to use the "lazy" attribute to specify what is loaded into a dom4j object graph. Really there is not a good way to only serialize only part of a dom4j xml object graph. In my case, I have a large graph, with a large amount of data, so loading the whole object graph provides way too much overhead.

I realize I could accomplish this using separate xml "entities" for the same table, but this is alot of extra mapping, and really isn't very maintainable.

The other alternative is to just fetch the actual pojo object graph, then use one of the many object to xml marshalling frameworks. However, this seems like alot of extra overhead, and requires some unique conventions to handle hibernate proxy classes (JAXB custom Accessors for example).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.