-->
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: Hibernate Search: Indexing performing unnecessary queries
PostPosted: Tue Jul 28, 2009 5:20 pm 
Newbie

Joined: Wed Oct 20, 2004 3:05 pm
Posts: 3
I am trying to index a small portion of a rather complex Hibernate graph. My document root class has two @ManyToOne relationships. Only one of those relationships has the @IndexEmbedded annotation on it. When attempting to index my base class, using the strategy outlined in Hibernate Search in Action, I noticed that Hibernate is eagerly fetching all related beans, not just the ones with the @IndexEmbedded annotation. This results in thousands of completely unnecessary queries to be performed that have absolutely no real impact on the indexing process.

Code:
@Entity
@Table(name = "SOMETHING")
public class TestBean implements Serializable
{
   ...

   @ManyToOne(fetch=FetchType.LAZY)
   @JoinColumn(name = "FOO_ID", insertable=false, updatable= false)
   private FooBean foo;

   @ManyToOne
   @JoinColumn(name = "BAR_ID", insertable=false, updatable= false)
   @IndexEmbedded
   private BarBean bar;

   ...
}


My question is... is there any way to prevent Hibernate Search to only load entities that are demarcated with the @IndexEmbedded annotation rather than loading everything eagerly? I even explicitly set fetching to LAZY with no luck. I understand that people are recommending a fully hydrated graph before indexing, but I'm looking at a potential batch indexing time of 10 DAYS... uggggh

I know I could probably comment out the unnecessary relationship annotations temporarily just for the indexing, but it just seems like there could be a better way. Any help is appreciated. Thanks!


Top
 Profile  
 
 Post subject: Re: Hibernate Search: Indexing performing unnecessary queries
PostPosted: Fri Jul 31, 2009 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
there's a known limitation in @ManyToOne mappings, not really related to Search:
if you don't use the "optional=false" setting, having possible null values at the toOne side, then the FetchType.LAZY is being ignored.

Please verify my words: try loading a single entity turning on SQL logging, it should show you it's also loading the related entities.

_________________
Sanne
http://in.relation.to/


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.