Hello,
we had the following code:
@Entity(name = "EntityA")
@Indexed
public class EntityA{
...
@OneToMany
@IndexedEmbedded(structure = ObjectStructure.NESTED)
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private List<EntityB> b;
}
and we changed our data model to
@Entity(name = "EntityA")
@Indexed
public class EntityA{
...
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "entityA")
@IndexedEmbedded(structure = ObjectStructure.NESTED)
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private EntityB entityB;
}
@Entity(name = "EntityB")
public class EntityB{
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "entity_a_reference", insertable = false, updatable = false)
private EntityA entityA;
}
since this change we are getting the following error:
org.hibernate.search.util.common.AssertionFailure: Attempted to detect entity type of object [] because a contained entity was modified, but this object does not seem to be an entity. -- this may indicate a bug or a missing test in Hibernate Search. Please report it: https://hibernate.org/community/
I am basically clueless… Could you please help me?
Thank you in advence!
Hello,
This could be a bug in Hibernate Search, or an invalid mapping in Hibernate ORM. Not sure with the provided information.
Please:
- Format your code correctly so that we can read it all, putting a line with three backticks before and after the code:
```
code
```
- Format your stacktrace correctly, same idea:
```
stacktrace
```
- Provide the relevant mapping of
EntityB
, in particular the inverse side of the association
- Provide the full stack trace
EDIT: BTW you’re asking on a Friday afternoon, so… be prepared to only get an actual answer on Tuesday (busy on Monday). Sorry
no problem at all, i also did not expect from you to investigate it right now, i just thought might be an obvious tiny problem that I have overseen. Code is now formatted but I can not insert a stack trace because it is too long, here is a screenshot instead.
I don’t see an @Entity
on EntityA
, is that an oversight? Are you using XML mapping, maybe?
I think I’ll really need the whole relevant mapping to investigate. So, EntityA
, EntityB
, and all associations between them, in both ways.
Updated, thanks in advance! Have a nice weekend!
Problem solved, it was indeed a mapping problem, we had also in the parent of EntityB a column named entity_a_reference - I removed that of course and also had to remove insertable = false, updatable = false , works like this
@Entity(name = "EntityA")
@Indexed
public class EntityA{
...
@OneToOne(fcascade = CascadeType.ALL, mappedBy = "entityA")
@IndexedEmbedded
@IndexingDependency(reindexOnUpdate = ReindexOnUpdate.SHALLOW)
private EntityB entityB;
}
@Entity(name = "EntityB")
public class EntityB{
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "entity_a_reference")
private EntityA entityA;
}
1 Like