Identifiers
All about entity identifiers, from primary keys, and generators to composite keys and field types.
Last updated
Was this helpful?
All about entity identifiers, from primary keys, and generators to composite keys and field types.
Last updated
Was this helpful?
Identifier properties are denoted via fieldtype="id"
.
We highly recommend disabling updates on identifier properties via update="false"
:
The Assigned generator is the default identifier generator type, and simply allows the application (your CFML) to assign identifier values prior to insertion. You can think of this as generator=none
.
lets the application assign an identifier to the object before save() is called. This is the default strategy if no element is specified. -
Assigned generators will commonly use to assign the identifer value:
A select generator will attempt to select the next identifier value from the specified selectKey
column:
The UUID generator uses Hibernate's uuid generator under the hood:
The Increment generator uses a simple incrementing value to create identifiers. Do not use in concurrent applications, as the values may no longer be unique.
There are several lesser-known identifier generator types, including:
foreign
- use a foreign CFC's generator configuration
seqhilo
sequence
select
- select the next value from the column denoted in selectKey
uuid
- use Hibernate's UUID generation
retrieves a primary key, assigned by a database trigger, by selecting the row by some unique key and retrieving the primary key value. -
uses a 128-bit UUID algorithm to generate identifiers of type string that are unique within a network (the IP address is used). The UUID is encoded as a string of 32 hexadecimal digits in length. -
Generates identifiers of type long, short or int that are unique only when no other process is inserting data into the same table. Do not use in a cluster. -