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!