christophe_grosjean wrote:
Thank you for your answer.
But in fact, in other words, my question is :
From a result set contains rows about Employee and Student, how can hibernate know that it has to instantiate an Employee or a Student ?
With discriminator, it's obvious... but here...
Prehaps it helps you.
This is a query generated by hibernate where I've:
Exception (Abstract on mapping)
--- ExpirationException
--- ProcessException (Abstract on mapping)
--- CotaException
--- ExclussionException
SELECT
this_.ID as ID0_,
this_.EXCEPTION_RULE as EXCEPTION2_1_0_,
this_.JUSTIFICATION as JUSTIFIC3_1_0_,
this_.VIGENCIA_DESDE as VIGENCIA4_1_0_,
this_.VIGENCIA_HASTA as VIGENCIA5_1_0_,
this_.ID_CAUSE as ID6_1_0_,
this_.TO_DATE as TO1_2_0_,
this_.GENERAL_EXP_DATE as GENERAL2_2_0_,
this_.clazz_ as clazz_0_
FROM
(
select nullif('x',
'x') as TO_DATE,
ID_CAUSE,
JUSTIFICATION,
VIGENCIA_DESDE,
VIGENCIA_HASTA,
nullif('2000-1-1',
'2000-1-1') as GENERAL_EXP_DATE,
EXCEPTION_RULE,
ID,
3 as clazz_ from EXCEPCION.EXCLUSION_EXCEPTION_ENTITY
union all
select nullif('x',
'x') as TO_DATE,
ID_CAUSE,
JUSTIFICATION,
VIGENCIA_DESDE,
VIGENCIA_HASTA,
nullif('2000-1-1',
'2000-1-1') as GENERAL_EXP_DATE,
EXCEPTION_RULE,
ID,
4 as clazz_ from EXCEPCION.COTA_EXCEPTION_ENTITY
union all
select TO_DATE,
ID_CAUSE,
JUSTIFICATION,
VIGENCIA_DESDE,
VIGENCIA_HASTA,
GENERAL_EXP_DATE,
EXCEPTION_RULE,
ID,
1 as clazz_ from EXCEPCION.EXPIRATION_EXCEPTION_ENTITY ) this_
As you can see, Hibernate put and clazz_ column where put a number (1, 4 or 3) depending on the subclass it is querying on.
YOu cant see a query to Exception or ProcessException because they are abstracts on mapping.
I think it's used to discriminate the class to be instanciated.
I hope it helps
Regards
German.-