org.openmrs.api.db.hibernate
Class NativeIfNotAssignedIdentityGenerator

java.lang.Object
  extended by org.hibernate.id.AbstractPostInsertGenerator
      extended by org.hibernate.id.IdentityGenerator
          extended by org.openmrs.api.db.hibernate.NativeIfNotAssignedIdentityGenerator
All Implemented Interfaces:
org.hibernate.id.Configurable, org.hibernate.id.IdentifierGenerator, org.hibernate.id.PostInsertIdentifierGenerator

public class NativeIfNotAssignedIdentityGenerator
extends org.hibernate.id.IdentityGenerator
implements org.hibernate.id.Configurable

native-if-not-assigned

By setting the Hibernate configuration's primary key column to use a "native" implementation, Hibernate ALWAYS generates the entity's id when it is being saved. There is no way to "override" the generated id.

This IdentityGenerator allows a programmer to override the "generated" id, with an "assigned" id at runtime by simply setting the primary key property.

Author:
paul.shemansky@gmail.com

Nested Class Summary
 
Nested classes/interfaces inherited from class org.hibernate.id.IdentityGenerator
org.hibernate.id.IdentityGenerator.BasicDelegate, org.hibernate.id.IdentityGenerator.GetGeneratedKeysDelegate, org.hibernate.id.IdentityGenerator.InsertSelectDelegate
 
Field Summary
 
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME
 
Constructor Summary
NativeIfNotAssignedIdentityGenerator()
           
 
Method Summary
 void configure(org.hibernate.type.Type type, java.util.Properties params, org.hibernate.dialect.Dialect dialect)
           
 java.io.Serializable generate(org.hibernate.engine.SessionImplementor session, java.lang.Object entity)
           
 
Methods inherited from class org.hibernate.id.IdentityGenerator
getInsertGeneratedIdentifierDelegate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NativeIfNotAssignedIdentityGenerator

public NativeIfNotAssignedIdentityGenerator()
Method Detail

generate

public java.io.Serializable generate(org.hibernate.engine.SessionImplementor session,
                                     java.lang.Object entity)
                              throws org.hibernate.HibernateException
Specified by:
generate in interface org.hibernate.id.IdentifierGenerator
Overrides:
generate in class org.hibernate.id.AbstractPostInsertGenerator
Throws:
org.hibernate.HibernateException

configure

public void configure(org.hibernate.type.Type type,
                      java.util.Properties params,
                      org.hibernate.dialect.Dialect dialect)
               throws org.hibernate.MappingException
Specified by:
configure in interface org.hibernate.id.Configurable
Throws:
org.hibernate.MappingException
See Also:
Configurable.configure(org.hibernate.type.Type, java.util.Properties, org.hibernate.dialect.Dialect)

OpenMRS-1.7.x

Generated Apr 27 2012 10:06 PM. NOTE - these libraries are in active development and subject to change