-->
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: Bidirectional one-to-many collection does recursive fetching
PostPosted: Thu Sep 14, 2006 3:34 am 
Newbie

Joined: Wed Dec 21, 2005 4:41 am
Posts: 2
Location: Belgium
Hibernate version: 3.1.3

I'm having a problem with a class Contract that has many mapped Sets, e.g.:

Code:
   /**
    * @hibernate.set                    lazy="true" inverse="true"
    * @hibernate.collection-key         column="cntr_id"
    * @hibernate.collection-one-to-many class="com.jnj.eicd.model.DocumentHistory" 
    */
   public Set getDocumentHistory() {
      return documentHistory;
   }

   public void setDocumentHistory(Set documentHistory) {
      this.documentHistory = documentHistory;
   }

   /**
    * @hibernate.set                    lazy="true" inverse="true"
    * @hibernate.collection-key         column="cntr_id"
    * @hibernate.collection-one-to-many class="com.jnj.eicd.model.ContractVariable" 
    */
   public Set getContractVariables() {
      return contractVariables;
   }

   public void setContractVariables(Set contractVariables) {
      this.contractVariables = contractVariables;
   }


Both are bidirectional, and at the other end both associations are mapped as such:

Code:
   /**
    * @hibernate.many-to-one column="cntr_id" class="com.jnj.eicd.model.Contract"
    */
   public Contract getContract() {
      return contract;
   }
   
   public void setContract(Contract contract) {
      this.contract = contract;
   }


These are just two of 22 mapped Sets in Contract.java. Most of these sets are fetched correctly. When I do a getContractVariables().size(), the generated SQL fetches no more than is necessary.

However, when I do a getDocumentHistory().size(), it follows the association in DocumentHistory back to Contract and thuis joins with Contract again, resulting in a 466 line SQL query (after formatting in TOAD), where it could be done in much, much less. It does this with at least 4 of the other Sets as well. This results in a major slowdown of the application.

I can't see any difference in mapping between those that work correctly and those that don't. If anyone could point me in a right direction as to where to look, I'd be much obliged.


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.