Query "select count(h) from Human h" fails if a subclass has a non-Id property named "id"

Description

Given the following classes:

Executing the query: select count( h ) from Human h results in the following SQL:

Note that:

  • idproperty0_.id is not the primary key column;

  • Human does not have a property named id;

  • count should be operating on the primary key, idproperty0_.realId.

The same select expression is generated using @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS).

When @Inheritance(strategy = InheritanceType.JOINED) is used, the generated SQL is:

In addition to using the wrong column, there is no table with alias idproperty0_1_.

Environment

None

Assignee

Andrea Boriero

Reporter

Gail Badner

Fix versions

Labels

None

backPortable

Backport?

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure