Chicken and egg problem with @SqlFragmentAlias


#1

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 ?


#2

Sounds like a bug. Try to replicate it like this or with our test case template and open a Jira issue afterward.


#3

Thanks Vlad, I was able to re-create the problem in a test case and created https://hibernate.atlassian.net/browse/HHH-12967

Bas


#4

Thanks for the Jira issue and test case.


#5

What is the normal timeframe for someone to read the issue?


#6

There’s no timeframe. The team is focused on 6.0 development and only high priority issues get more attention.

If you want to see it fixed sooner, send us a Pull Request with the fix and we’ll review it. Pull Requests have a higher priority too.


#7

Good to know, I was waiting on some kind of acknowledgement thinking someone monitored that.
I will need to set that up on my private laptop but will try to find some time.


#8

Looking forward to reviewing your Pull Request.