er.extensions.eof
Class ERXLongPrimaryKeyFactory
java.lang.Object
er.extensions.eof.ERXLongPrimaryKeyFactory
public class ERXLongPrimaryKeyFactory
- extends java.lang.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
Method Summary |
static com.webobjects.foundation.NSDictionary |
primaryKeyDictionary(com.webobjects.eocontrol.EOEnterpriseObject eo)
|
static java.lang.Object |
primaryKeyValue(java.lang.String entityName)
|
com.webobjects.eoaccess.EOEntity |
subEntityForEntity(com.webobjects.eoaccess.EOEntity entity,
com.webobjects.foundation.NSDictionary pkDict)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ERXLongPrimaryKeyFactory
public ERXLongPrimaryKeyFactory()
subEntityForEntity
public com.webobjects.eoaccess.EOEntity subEntityForEntity(com.webobjects.eoaccess.EOEntity entity,
com.webobjects.foundation.NSDictionary pkDict)
primaryKeyValue
public static java.lang.Object primaryKeyValue(java.lang.String entityName)
primaryKeyDictionary
public static com.webobjects.foundation.NSDictionary primaryKeyDictionary(com.webobjects.eocontrol.EOEnterpriseObject eo)
Copyright © 2002 – 2007 Project Wonder.