I'm a beginner in Hibernate : I try to use annotations.
In purpose i try to use org.hibernate.annotations.LazyCollectionOption.EXTRA
For that on my entity i annotate one member like that :
Code:
@OneToMany(fetch = FetchType.LAZY, mappedBy = "banque")
@org.hibernate.annotations.LazyCollection(
org.hibernate.annotations.LazyCollectionOption.EXTRA)
private List<CompteEnBanque> listCpt = new ArrayList<CompteEnBanque>();
The Class CompteEnBanque is a SuperClass(with strategy = InheritanceType.TABLE_PER_CLASS), and their two subclasses are "comptes_epargne" and "comptes_courant",
So when I try to get size of listCpt, I have this SQL query generated by Hibernate :
Code:
select
count(id)
from
( select
id,
plafond,
solde,
compteEnBanque_AssuranceID,
compte_banqueID,
remuneration,
1 as clazz_
from
comptes_epargne
union
select
id,
plafond,
solde,
compteEnBanque_AssuranceID,
compte_banqueID,
null as remuneration,
2 as clazz_
from
comptes_courant
)
where
compte_banqueID = ?
And i've got this error : org.hibernate.util.JDBCExceptionReporter - Every derived table must have its own alias
Missing an alias on subselect, how i can fix that ?
I use MySQL DB.
Thanks in advance for your help