When mapping a subclass hierarchy using the dicriminator-column and repeating the discriminator as a key property, the SQL generated for paging queries to an Oracle DB is invalid.
The reason seems to be that the paging operation wraps the query in a subselect to add the rownumber used for paging. The original query contains the discriminator twice:
Code:
SELECT id as id, type as type, type as type from SUPPLIER
Using this statement in a subselect causes Oracle to throw an "Ambiguous column name" error.
Possible fix:
in the EntityPersister constructor
Code:
public EntityPersister(PersistentClass model, SessionFactoryImplementor factory)
change the generated discriminator alias (line 712) from:
Code:
discriminatorAlias = column.getAlias();
to
Code:
discriminatorAlias = column.getAlias() + "__";
This will cause the discriminator name to not overlap with the name of the key property column in the SQL code.
Hibernate version: 2.1.8
Name and version of the database you are using: Oracle 10g