I have a entity A with an @Filter definition with an SqlFragmentAlias using entity B.
@Filter(
name = "myFilter",
condition =
"{alias}.AHC_ID = {allowed}.AHC_ID and {allowed}.PERSON_ID=:"
+ AHCScopedFilters.P_PERSONID,
deduceAliasInjectionPoints = false,
aliases = {
@SqlFragmentAlias(alias = "allowed", entity=B.class)
})
When hibernate creates the factory it blows up with an entity not found exception “B”.
We are using JPA running in jBoss EAP 7 that uses hibernate 5.0
Both classes are defined in the persistence.xml file and what I see is that the metadata.getEntityBindings contains all of our classes. The problem arises in the SessionFactoryImpl constructor that loops through the metaData.entityBindings and then adds them to its own entityPersisters map.
It first processes entity A and when it handles the filter it then throws that exception because it is looking into this persisters map but entity B has not been processes yet and thus is not in that map yet.
Is this a bug or is there some property I can set that will do some 2-phased approach when loading the entities ?