Show Table of Contents
14.6. Referring to Identifier Property
There are 2 ways to refer to an entity's identifier property:
- The special property (lowercase)
idmay be used to reference the identifier property of an entity provided that the entity does not define a non-identifier property named id.
- If the entity defines a named identifier property, you can use that property name.
References to composite identifier properties follow the same naming rules. If the entity has a non-identifier property named id, the composite identifier property can only be referenced by its defined named. Otherwise, the special
idproperty can be used to reference the identifier property.
Please note that, starting in Hibernate version 3.2.2, this has changed significantly. In previous versions,
idalways referred to the identifier property regardless of its actual name. A ramification of that decision was that non-identifier properties named
idcould never be referenced in Hibernate queries.