Lets supose that I have 3 abstract super classes: SuperA, SuperB and SuperC.
Lets supose that each of theses super classes had a lot of more specific implementations, and all the superclasses are annotated with @Inheritance(strategy = InheritanceType.JOINED).
More specific:
Aa<-SuperAand has a List ofSuperB(thebbsproperty);Bb<-SuperBand has a List ofSuperC(theccsproperty);Cc<-SuperCand has afooproperty.
Then, when I try a query like the following, I got an error saying that it could not find the property foo in the type SuperC. Bb has a list of the abstract type, and I can’t change that. So, I do not know how to make the query works.
select a from Aa a left outer join a.bbs b where b.ccs.foo = :foo
Any tip will help. Thanks in advance.
Edit:
BTW: the exception:
org.hibernate.exception.SQLGrammarException: Unknown column 'cc3_1_.foo' in 'where clause'
Edit 2:
I look for JPA docs, and found something that could work, if I’m not using Hibernate.
Edit 3:
I change it to use two SQL’s. First, I find the id of the C based on the foo property, then I just do the query comparing with the id.
The problem here, is that I have to do 2 SQL’s for every time I want this… but, at least it works.
You need one more join for the list of Cc’s then it should be fine:
as ccs is a list you can’t “dereference” it’s property this way, if you could you wouldn’t need joins, you could simply write:
a.bbs.ccs.foobut this is not the case so you need to join the lists as I wrote above.