Project Wonder 5.0.0.8795

er.extensions.eof
Class ERXLongPrimaryKeyFactory

java.lang.Object
  extended by er.extensions.eof.ERXLongPrimaryKeyFactory

public class ERXLongPrimaryKeyFactory
extends Object

Author:
david@cluster9.com

Automatically generates Long primary keys for entities. Features a cache which reduces database roundtrips as well as optionally encoding Entity type in PK value.

usage:

override either the ERXGeneratesPrimaryKey interface like this:
 private NSDictionary _primaryKeyDictionary = null;
 
 public NSDictionary primaryKeyDictionary(boolean inTransaction) {
                if (_primaryKeyDictionary == null) {
                        _primaryKeyDictionary = ERXLongPrimaryKeyFactory.primaryKeyDictionary(this);
                }
                return _primaryKeyDictionary;
 }
 

or manually call
ERXLongPrimaryKeyFactory.primaryKeyDictionary(EOEnterpriseObject eo);

the necessary database table is generated on the fly.

Encoding Entity in PK values
If the system property ERXIntegerPrimaryKeyFactory.encodeEntityInPkValue is set to true then the last 6 bits from the 64 bit primary key is used to encode the Subentity in the pk value. This speeds up inheritance with multiple tables. In order to support this you must add an entry to the userInfo from the Subentities:

key=entityCode
value= %lt;%lt; an unique integer, no longer than 6 bit - 1

Constructor Summary
ERXLongPrimaryKeyFactory()
           
 
Method Summary
static NSDictionary primaryKeyDictionary(EOEnterpriseObject eo)
           
static Object primaryKeyValue(String entityName)
           
 EOEntity subEntityForEntity(EOEntity entity, NSDictionary pkDict)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXLongPrimaryKeyFactory

public ERXLongPrimaryKeyFactory()
Method Detail

subEntityForEntity

public EOEntity subEntityForEntity(EOEntity entity,
                                   NSDictionary pkDict)

primaryKeyValue

public static Object primaryKeyValue(String entityName)

primaryKeyDictionary

public static NSDictionary primaryKeyDictionary(EOEnterpriseObject eo)

Last updated: Fri, Jan 9, 2009 • 04:35 AM EST

Copyright © 2002 – 2007 Project Wonder.