Example usage for org.hibernate.id IdentifierGeneratorHelper POST_INSERT_INDICATOR

List of usage examples for org.hibernate.id IdentifierGeneratorHelper POST_INSERT_INDICATOR

Introduction

In this page you can find the example usage for org.hibernate.id IdentifierGeneratorHelper POST_INSERT_INDICATOR.

Prototype

Serializable POST_INSERT_INDICATOR

To view the source code for org.hibernate.id IdentifierGeneratorHelper POST_INSERT_INDICATOR.

Click Source Link

Document

Marker object returned from IdentifierGenerator#generate to indicate that the entity's identifier will be generated as part of the datbase insertion.

Usage

From source file:org.primeframework.persistence.hibernate.GeneratedKeysGenerator.java

License:Open Source License

/**
 * If the Entity is Identifiable and has an ID, this returns that ID. Otherwise, this returns the
 * POST_INSERT_INDICATOR to tell Hibernate to not send anything in the insert statement and let the database generate
 * it./*w  w  w .j ava  2s  . c o  m*/
 *
 * @param s   Not used.
 * @param obj Checked to see if it is Identifiable.
 * @return The Identifiable ID or the POST_INSERT_INDICATOR.
 */
@Override
public Serializable generate(SessionImplementor s, Object obj) {
    if (obj instanceof Identifiable) {
        Identifiable i = (Identifiable) obj;
        if (i.getId() != null) {
            return i.getId();
        }
    }

    return IdentifierGeneratorHelper.POST_INSERT_INDICATOR;
}