-->
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.  [ 9 posts ] 
Author Message
 Post subject: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Tue May 07, 2013 12:15 am 
Newbie

Joined: Tue May 07, 2013 12:00 am
Posts: 8
Location: The Middle of Middle Earth!
Hello,
I have the following setup.

Code:
public abstract class Entity {
   @IndexedEmbedded
   private EntitySummary entitySummary;
}

public class EntitySummary {
   @IndexedEmbedded
   private EntityState state;
   @ContainedIn
   private Entity entity;
}

@Indexed(index = "Item")
public class IndexedItem extends Entity {
}

//Please note that this class is not indexed.
public class NonIndexedItem extends Entity {
}



When I persist IndexedItem, it's all good -Index is getting created and data is getting persisted to the database

When I try to persist NonIndexedItem, I'm not expecting Hibernate Search to index NonIndexedItem since I've not specified @Indexed for the class, but apparently, Hibernate Search is trying to index it (because of my @Container annotation in EntitySummary ?)and fails with the below error

Code:
org.hibernate.search.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class com.bla.NonIndexedItem


Is there any way I can persist NonIndexedItem without having to index it? I would really appreciate any thoughts on this.

Thanks


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Tue May 07, 2013 11:52 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi,
I think you've hit a bug. Quite an interesting corner case actually!

You should be able to workaround the problem by marking your NonIndexedItem as @Indexed and then apply an Indexing Interceptor to always disable indexing for the specific type; see also: http://docs.jboss.org/hibernate/search/4.3/reference/en-US/html_single/#search-mapping-indexinginterceptor

I'll report it as a bug on JIRA and will see if we can fix it in the 4.3 or 4.4 timeframe; I can't commit on the timing as it might seem simple but it's actually a very tricky one.

It is possibly I might not be able to reproduce it with a simple persist: it would be very helpfull if you could create a unit test, as the devil is in the details.

https://hibernate.atlassian.net/browse/HSEARCH-1318

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


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Tue May 07, 2013 6:35 pm 
Newbie

Joined: Tue May 07, 2013 12:00 am
Posts: 8
Location: The Middle of Middle Earth!
Thanks Sanne, I really appreciate your feedback. Yep, writing an interceptor that skips indexing seems to be doing the job.

I'll create a detailed test case and upload it to your JIRA ticket.

Thanks.


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Wed Aug 14, 2013 12:25 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Mark,
a test case would be very appreciated. I've tried to forge one but we need some help as it's triggered only by a specific combination of mapping and a specific data set.

If you can't provide a full unit test, could you please post the missing mapping? I didn't realize initially, but in the example you posted we're missing the mapping of EntityState, which seems might be relevant.

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


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Thu Aug 15, 2013 12:44 am 
Newbie

Joined: Tue May 07, 2013 12:00 am
Posts: 8
Location: The Middle of Middle Earth!
My bad, Sorry. I had completely forgotten about the test case. I should be able to reproduce the problem and provide you with a little test case when I come into work tomorrow. My apologies.

Cheers!


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Tue Aug 20, 2013 1:04 am 
Newbie

Joined: Tue May 07, 2013 12:00 am
Posts: 8
Location: The Middle of Middle Earth!
I was trying to create a little test case with a simplified domain model, but cannot seem to recreate the problem.

A test case on our complete domain model does recreate the problem. Our domain model is a bit nasty, so many levels of inheritance and composition, I just don't want to dump the entire model on you and say "you figure out what's wrong".

Lemme take this home and do a little more work on it. I know it's not rocket science, it's just a matter of finding out exactly where it breaks. (There seems to be some problem with atlassian sign up, couldn't get to update the ticket)

Sorry for the delay, a 6.6 shake drove us all away from work and made us take refuge in open roof bars for the last couple of days. I'm still shaking - I don't know if it's the earthquake or the alcohol!

Cheers!


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Mon Sep 02, 2013 10:38 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Mark,
no worries and thanks for your investigation! I hope you stopped shaking by now ;-) I have been away myself for some days.

the atlassian signup problem has been reported to Atlassian, thanks.

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


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Tue Sep 03, 2013 6:55 pm 
Newbie

Joined: Tue May 07, 2013 12:00 am
Posts: 8
Location: The Middle of Middle Earth!
Hi Sanne,
I think I may have found the problem. I believe it is not necessarily a Hibernate Search issue(kind of)

The exception is thrown only in our tests which made me wonder if it was our DSL constructors that are responsible for the problem.

Domain objects:
---------------
Code:
public abstract class Entity {
   @IndexedEmbedded
   private EntitySummary entitySummary;
}

public class EntitySummary {
   @IndexedEmbedded
   private EntityState state;
   @ContainedIn
   private Entity entity;
}

@Indexed(index = "Item")
public class IndexedItem extends Entity {
}

//Please note that this class is not indexed.
public class NonIndexedItem extends Entity {
}


This works sweet :
-----------------
Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {bla bla bla...})
public Class NonIndexedItemTest extends AbstractTransactionalJUnit4SpringContextTests {
   @Test
   public void test() {
      NonIndexedItem item = new NonIndexedItem();
      //set item properties
      entityManager.persist(item);
   }
}


This doesn't work:
-----------------
(Exception thrown : org.hibernate.search.SearchException: Unable to perform work. Entity Class is not @Indexed nor hosts @ContainedIn: class com.bla.NonIndexedItem)

Code:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {bla bla bla...})
public Class NonIndexedItemTest extends AbstractTransactionalJUnit4SpringContextTests {
   @Test
   public void test() {
      //this will create a NonIndexedItem and persist it to the database.
      NonIndexedItem item = NonIndexedItemConstructor.item().persistent(persistenceService).fixture();
   }
}


Obviously, we're doing something weird in our DSL constructors that *triggers* this exception.

I will keep you posted if I manage to find out as why our DSL constructors are triggering this exception, but it appears to me that this may not be a bug with Hibernate Search itself.

Thanks for your help on this, I really appreciate it.

Cheers!


Top
 Profile  
 
 Post subject: Re: Search : Entity Class is not @Indexed nor hosts @ContainedIn
PostPosted: Wed Sep 04, 2013 5:54 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Hi Mark,
thanks for the investigation! I've marked the issue resolved as "can't reproduce", if you happen to find out it actually was a problem in Search, we can open a new one.

_________________
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.  [ 9 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.