Identifier refers to the attribute name of <id>
element in .hbm
file or @Id
annotation.
Mark the identifier property with @Id
.
@Entity
public class Person {
@Id Integer getId() { ... }
...
}
In hbm.xml
, use the <id>
element which defines the mapping from that property to the primary key column.
<id
name="propertyName"
type="typename"
column="column_name"
unsaved-value="null|any|none|undefined|id_value"
access="field|property|ClassName">
node="element-name|@attribute-name|element/@attribute|."
<generator class="generatorClass"/>
</id>
- name (optional): the name of the identifier property.
- type (optional): a name that indicates the Hibernate type.
- column (optional - defaults to the property name): the name of the primary key column.
- unsaved-value (optional - defaults to a "sensible" value): an identifier property value that indicates an instance is newly instantiated (unsaved), distinguishing it from detached instances that were saved or loaded in a previous session.
- access (optional - defaults to property): the strategy Hibernate should use for accessing the property value.
Related link