Ortus ORM Extension
  • Introduction
    • Release History
      • What's New With 6.x
      • What's New With 5.x
    • About This Book
  • Getting Started
    • Installation
    • Configuration
      • Custom Hibernate Config
      • Secondary Caches
      • Logging
  • Modeling
    • Entities
    • Identifiers
    • Properties
    • Relationships
  • Usage
    • Built-In Functions
    • Querying
    • Events
    • Session Management
    • HQL
    • Transactions
    • Caching
  • External Links
    • API Docs for v6.5.2
    • Source Code
    • Issue Tracker
Powered by GitBook
On this page
  • Common Generator Types
  • Assigned Generator
  • Select Generator
  • UUID Generator
  • Increment Generator

Was this helpful?

Edit on GitHub
Export as PDF
  1. Modeling

Identifiers

All about entity identifiers, from primary keys, and generators to composite keys and field types.

PreviousEntitiesNextProperties

Last updated 1 year ago

Was this helpful?

Identifier properties are denoted via fieldtype="id".

We highly recommend disabling updates on identifier properties via update="false":

property name="id"
            fieldtype="id"
            ormtype="string"
            generator="assigned"
            update="false";

Common Generator Types

Assigned Generator

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. -

property name="id"
            fieldtype="id"
            generator="assigned"
            update="false";

Assigned generators will commonly use to assign the identifer value:

function preInsert( entity ){
    setId( createUUID() );
}

Select Generator

A select generator will attempt to select the next identifier value from the specified selectKey column:

property name="userID"
            fieldtype="id"
            generator="select"
            selectKey="ssn"
            update="false";

UUID Generator

The UUID generator uses Hibernate's uuid generator under the hood:

property name="userID"
            fieldtype="id"
            generator="uuid"
            update="false";

Increment Generator

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.

property name="userID"
            fieldtype="id"
            generator="increment"
            update="false";

Other Valid Generator Types

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. -

Hibernate 3.3 mapping reference docs
Hibernate 3.3 mapping reference docs
Hibernate 3.3 mapping reference docs
Hibernate 3.3 mapping reference docs
a preInsert() event listener