diff --git a/lib/Doctrine.php b/lib/Doctrine.php index af294e7aa..1d91434e7 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -289,7 +289,7 @@ final class Doctrine /** * FETCHMODE_RECORD * - * Specifies that the fetch method shall return Doctrine_Record + * Specifies that the fetch method shall return Doctrine_Entity * objects as the elements of the result set. * * This is the default fetchmode. @@ -471,6 +471,14 @@ final class Doctrine * @see self::ATTR_HYDRATE */ const HYDRATE_NONE = 4; + + /* new hydration modes. move to Query class when it's time. */ + //const HYDRATE_IDENTITY_OBJECT = 1; // default, auto-adds PKs, produces object graphs + //const HYDRATE_IDENTITY_ARRAY = 2; // auto-adds PKs, produces array graphs + //const HYDRATE_SCALAR = 3; // produces flat result list with scalar values + //const HYDRATE_SINGLE_SCALAR = 4; // produces a single scalar value + //const HYDRATE_NONE = 5; // produces a result set as it's returned by the db + /** * VALIDATE CONSTANTS @@ -709,8 +717,8 @@ final class Doctrine * * Get all the loaded models, you can provide an array of classes or it will use get_declared_classes() * - * Will filter through an array of classes and return the Doctrine_Records out of them. - * If you do not specify $classes it will return all of the currently loaded Doctrine_Records + * Will filter through an array of classes and return the Doctrine_Entitys out of them. + * If you do not specify $classes it will return all of the currently loaded Doctrine_Entitys * * @return array $loadedModels */ @@ -747,7 +755,7 @@ final class Doctrine /** * isValidModelClass * - * Checks if what is passed is a valid Doctrine_Record + * Checks if what is passed is a valid Doctrine_Entity * Will load class in to memory in order to inflect it and find out information about the class * * @param mixed $class Can be a string named after the class, an instance of the class, or an instance of the class reflected @@ -755,7 +763,7 @@ final class Doctrine */ public static function isValidModelClass($class) { - if ($class instanceof Doctrine_Record) { + if ($class instanceof Doctrine_Entity) { $class = get_class($class); } @@ -766,10 +774,10 @@ final class Doctrine if ($class instanceof ReflectionClass) { // Skip the following classes // - abstract classes - // - not a subclass of Doctrine_Record + // - not a subclass of Doctrine_Entity // - don't have a setTableDefinition method if (!$class->isAbstract() && - $class->isSubClassOf('Doctrine_Record')) { + $class->isSubClassOf('Doctrine_Entity')) { return true; } @@ -805,7 +813,7 @@ final class Doctrine /** * generateModelsFromDb * - * method for importing existing schema to Doctrine_Record classes + * method for importing existing schema to Doctrine_Entity classes * * @param string $directory Directory to write your models to * @param array $databases Array of databases to generate models for diff --git a/lib/Doctrine/AuditLog.php b/lib/Doctrine/AuditLog.php index 23fc598eb..111ccc80a 100644 --- a/lib/Doctrine/AuditLog.php +++ b/lib/Doctrine/AuditLog.php @@ -55,11 +55,11 @@ class Doctrine_AuditLog extends Doctrine_Record_Generator /** * Get the version * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @param mixed $version * @return array An array with version information */ - public function getVersion(Doctrine_Record $record, $version) + public function getVersion(Doctrine_Entity $record, $version) { $className = $this->_options['className']; diff --git a/lib/Doctrine/Builder/Record.php b/lib/Doctrine/Builder/Record.php index 196651541..d075a44cc 100644 --- a/lib/Doctrine/Builder/Record.php +++ b/lib/Doctrine/Builder/Record.php @@ -22,7 +22,7 @@ /** * Doctrine_Builder_Record * - * Import builder is responsible of building Doctrine_Record classes + * Import builder is responsible of building Doctrine_Entity classes * based on a database schema. * * @package Doctrine @@ -93,7 +93,7 @@ class Doctrine_Builder_Record * * @var string */ - protected $_baseClassName = 'Doctrine_Record'; + protected $_baseClassName = 'Doctrine_Entity'; /** * tpl @@ -270,7 +270,7 @@ END; } /* - * Build the table definition of a Doctrine_Record object + * Build the table definition of a Doctrine_Entity object * * @param string $table * @param array $tableColumns diff --git a/lib/Doctrine/ClassMetadata.php b/lib/Doctrine/ClassMetadata.php index 4db380493..7eda783f9 100644 --- a/lib/Doctrine/ClassMetadata.php +++ b/lib/Doctrine/ClassMetadata.php @@ -137,6 +137,14 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * @var array $columns */ protected $_mappedColumns = array(); + + /** + * The mapped embedded values (value objects). + * + * @var array + * @TODO Implementation (Value Object support) + */ + protected $_mappedEmbeddedValues = array(); /** * An array of field names. used to look up field names from column names. @@ -171,7 +179,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab protected $_tree; /** - * Cached column count, Doctrine_Record uses this column count when + * Cached column count, Doctrine_Entity uses this column count when * determining its state. * * @var integer @@ -1571,7 +1579,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * binds query parts to given component * * @param array $queryParts an array of pre-bound query parts - * @return Doctrine_Record this object + * @return Doctrine_Entity this object */ public function bindQueryParts(array $queryParts) { @@ -1585,7 +1593,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * * @param string $queryPart * @param mixed $value - * @return Doctrine_Record this object + * @return Doctrine_Entity this object */ public function bindQueryPart($queryPart, $value) { @@ -1719,7 +1727,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * * @param mixed $constraint either a SQL constraint portion or an array of CHECK constraints * @param string $name optional constraint name - * @return Doctrine_Record this object + * @return Doctrine_Entity this object * @todo Should be done through $_tableOptions */ public function check($constraint, $name = null) @@ -1834,7 +1842,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * @param string $componentName the name of the related component * @param string $options relation options * @see Doctrine_Relation::_$definition - * @return Doctrine_Record this object + * @return Doctrine_Entity this object */ public function hasOne() { @@ -1850,7 +1858,7 @@ class Doctrine_ClassMetadata extends Doctrine_Configurable implements Serializab * @param string $componentName the name of the related component * @param string $options relation options * @see Doctrine_Relation::_$definition - * @return Doctrine_Record this object + * @return Doctrine_Entity this object */ public function hasMany() { diff --git a/lib/Doctrine/ClassMetadata/Factory.php b/lib/Doctrine/ClassMetadata/Factory.php index dc7919eac..7c16f9105 100644 --- a/lib/Doctrine/ClassMetadata/Factory.php +++ b/lib/Doctrine/ClassMetadata/Factory.php @@ -79,7 +79,7 @@ class Doctrine_ClassMetadata_Factory $parentClasses = array(); $loadedParentClass = false; while ($parentClass = get_parent_class($parentClass)) { - if ($parentClass == 'Doctrine_Record') { + if ($parentClass == 'Doctrine_Entity') { break; } if (isset($classes[$parentClass])) { @@ -159,7 +159,7 @@ class Doctrine_ClassMetadata_Factory $className = $name; // get parent classes do { - if ($className === 'Doctrine_Record') { + if ($className === 'Doctrine_Entity') { break; } else if ($className == $name) { continue; diff --git a/lib/Doctrine/Collection.php b/lib/Doctrine/Collection.php index d83bce568..179327330 100644 --- a/lib/Doctrine/Collection.php +++ b/lib/Doctrine/Collection.php @@ -58,7 +58,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator /** * This record this collection is attached to, if any. * - * @var Doctrine_Record + * @var Doctrine_Entity */ protected $reference; @@ -308,7 +308,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator * * @return void */ - public function setReference(Doctrine_Record $record, Doctrine_Relation $relation) + public function setReference(Doctrine_Entity $record, Doctrine_Relation $relation) { $this->reference = $record; $this->relation = $relation; @@ -368,7 +368,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator /** * */ - public function search(Doctrine_Record $record) + public function search(Doctrine_Entity $record) { return array_search($record, $this->data, true); } @@ -388,7 +388,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator * Collection also maps referential information to newly created records * * @param mixed $key the key of the element - * @return Doctrine_Record return a specified record + * @return Doctrine_Entity return a specified record */ public function get($key) { @@ -481,15 +481,15 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator /** * set * @param integer $key - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return void - * @internal Can't type-hint the second parameter to Doctrine_Record because we need + * @internal Can't type-hint the second parameter to Doctrine_Entity because we need * to adhere to the Doctrine_Access::set() signature. */ public function set($key, $record) { - if ( ! $record instanceOf Doctrine_Record) { - throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Record'); + if ( ! $record instanceOf Doctrine_Entity) { + throw new Doctrine_Collection_Exception('Value variable in set is not an instance of Doctrine_Entity'); } if (isset($this->referenceField)) { @@ -500,14 +500,14 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator /** * adds a record to collection - * @param Doctrine_Record $record record to be added + * @param Doctrine_Entity $record record to be added * @param string $key optional key for the record * @return boolean */ public function add($record, $key = null) { - if ( ! $record instanceof Doctrine_Record) { - throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Record.'); + if ( ! $record instanceof Doctrine_Entity) { + throw new Doctrine_Record_Exception('Value variable in set is not an instance of Doctrine_Entity.'); } if (isset($this->referenceField)) { diff --git a/lib/Doctrine/Collection/Iterator.php b/lib/Doctrine/Collection/Iterator.php index 1afccee97..5b6325a49 100644 --- a/lib/Doctrine/Collection/Iterator.php +++ b/lib/Doctrine/Collection/Iterator.php @@ -96,7 +96,7 @@ abstract class Doctrine_Collection_Iterator implements Iterator /** * returns the current record * - * @return Doctrine_Record + * @return Doctrine_Entity */ public function current() { diff --git a/lib/Doctrine/Collection/Offset.php b/lib/Doctrine/Collection/Offset.php index eed595fb8..195151ad5 100644 --- a/lib/Doctrine/Collection/Offset.php +++ b/lib/Doctrine/Collection/Offset.php @@ -20,7 +20,7 @@ */ /** * Doctrine_Collection_Offset - * Collection of Doctrine_Record objects. + * Collection of Doctrine_Entity objects. * * @package Doctrine * @subpackage Collection diff --git a/lib/Doctrine/Connection.php b/lib/Doctrine/Connection.php index cacfa6136..8410c5048 100644 --- a/lib/Doctrine/Connection.php +++ b/lib/Doctrine/Connection.php @@ -144,6 +144,13 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun /* * ----------- EntityManager attributes --------------- */ + /** + * Enter description here... + * + * @var array + */ + private static $_ems = array(); + /** * The metadata factory is used to retrieve the metadata of entity classes. * @@ -1129,14 +1136,26 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun } + /* * ----------- EntityManager methods --------------- */ + /** + * Gets the EntityManager that is responsible for the Entity. + * + * @param string $entityName + * @return EntityManager + */ + public static function getManagerForEntity($entityName) + { + // ... + } + /** * query * queries the database using Doctrine Query Language - * returns a collection of Doctrine_Record objects + * returns a collection of Doctrine_Entity objects * * * $users = $conn->query('SELECT u.* FROM User u'); @@ -1148,7 +1167,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun * @param array $params query parameters * @param int $hydrationMode Doctrine::FETCH_ARRAY or Doctrine::FETCH_RECORD * @see Doctrine_Query - * @return Doctrine_Collection Collection of Doctrine_Record objects + * @return Doctrine_Collection Collection of Doctrine_Entity objects * @todo package:orm */ public function query($query, array $params = array(), $hydrationMode = null) @@ -1174,7 +1193,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun * @param string $query DQL query * @param array $params query parameters * @see Doctrine_Query - * @return Doctrine_Record|false Doctrine_Record object on success, + * @return Doctrine_Entity|false Doctrine_Entity object on success, * boolean false on failure */ public function queryOne($query, array $params = array()) @@ -1301,7 +1320,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun * * create creates a record * @param string $name component name - * @return Doctrine_Record Doctrine_Record object + * @return Doctrine_Entity Doctrine_Entity object * @todo Any strong reasons why this should not be removed? * @todo package:orm */ @@ -1377,12 +1396,12 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun $this->exported = array(); } - public function save(Doctrine_Record $entity, $conn = null) + public function save(Doctrine_Entity $entity, $conn = null) { $this->getMapper($entity->getClassName())->save($entity, $conn); } - public function remove(Doctrine_Record $entity, $conn = null) + public function remove(Doctrine_Entity $entity, $conn = null) { $this->getMapper($entity->getClassName())->delete($entity, $conn); } @@ -1392,17 +1411,17 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun return $this->getMapper($entityName)->create($data); } - public function detach(Doctrine_Record $entity) + public function detach(Doctrine_Entity $entity) { $this->getMapper($entity->getClassName())->detach($entity); } - public function removeRecord(Doctrine_Record $entity) + public function removeRecord(Doctrine_Entity $entity) { $this->getMapper($entity->getClassName())->removeRecord($entity); } - public function manage(Doctrine_Record $entity) + public function manage(Doctrine_Entity $entity) { $this->getMapper($entity->getClassName())->manage($entity); } @@ -1503,6 +1522,77 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun return $repository; } + + /** + * createEntity + * First checks if record exists in identityMap, if not + * returns a new record. + * + * @return Doctrine_Entity + */ + public function createEntity2($className, array $data) + { + $className = $this->_getClassnameToReturn($data, $className); + $classMetadata = $this->getClassMetadata($className); + if ( ! empty($data)) { + $identifierFieldNames = $classMetadata->getIdentifier(); + $isNew = false; + foreach ($identifierFieldNames as $fieldName) { + if ( ! isset($data[$fieldName])) { + // id field not found return new entity + $isNew = true; + break; + } + $id[] = $data[$fieldName]; + } + if ($isNew) { + return new $className(true, $data); + } + + $idHash = $this->unitOfWork->getIdentifierHash($id); + + if ($entity = $this->unitOfWork->tryGetByIdHash($idHash, + $classMetadata->getRootClassName())) { + // @todo return $entity; the one in-memory is the most recent. + $entity->hydrate($data); + } else { + $entity = new $className(false, $data); + $this->unitOfWork->registerIdentity($entity); + } + $data = array(); + } else { + $entity = new $className(true, $data); + } + + return $entity; + } + + /** + * Check the dataset for a discriminator column to determine the correct + * class to instantiate. If no discriminator column is found, the given + * classname will be returned. + * + * @return string The name of the class to instantiate. + * @todo Can be optimized performance-wise. + * @todo Move to EntityManager::createEntity() + */ + protected function _getClassnameToReturn(array $data, $className) + { + $class = $this->getClassMetadata($className); + + $discCol = $class->getInheritanceOption('discriminatorColumn'); + if ( ! $discCol) { + return $className; + } + + $discMap = $class->getInheritanceOption('discriminatorMap'); + + if (isset($data[$discCol], $discMap[$data[$discCol]])) { + return $discMap[$data[$discCol]]; + } else { + return $className; + } + } /* diff --git a/lib/Doctrine/Connection/UnitOfWork.php b/lib/Doctrine/Connection/UnitOfWork.php index 082bac886..7d3f0cdf2 100644 --- a/lib/Doctrine/Connection/UnitOfWork.php +++ b/lib/Doctrine/Connection/UnitOfWork.php @@ -119,7 +119,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module /** * Register a new entity. */ - public function registerNew(Doctrine_Record $entity) + public function registerNew(Doctrine_Entity $entity) { if ( ! $entity->identifier()) { throw new Doctrine_Connection_Exception("Entity without identity " @@ -136,7 +136,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module $this->_newEntities[$oid] = $entity; } - public function isRegisteredNew(Doctrine_Record $entity) + public function isRegisteredNew(Doctrine_Entity $entity) { return isset($this->_newEntities[$entity->getOid()]); } @@ -144,7 +144,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module /** * Registers a clean entity. */ - public function registerClean(Doctrine_Record $entity) + public function registerClean(Doctrine_Entity $entity) { $this->registerIdentity($entity); } @@ -152,7 +152,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module /** * Registers a dirty entity. */ - public function registerDirty(Doctrine_Record $entity) + public function registerDirty(Doctrine_Entity $entity) { if ( ! $entity->identifier()) { throw new Doctrine_Connection_Exception("Entity without identity " @@ -167,7 +167,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module } } - public function isRegisteredDirty(Doctrine_Record $entity) + public function isRegisteredDirty(Doctrine_Entity $entity) { return isset($this->_dirtyEntities[$entity->getOid()]); } @@ -175,7 +175,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module /** * Registers a deleted entity. */ - public function registerRemoved(Doctrine_Record $entity) + public function registerRemoved(Doctrine_Entity $entity) { if ($entity->isTransient()) { return; @@ -194,7 +194,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module } } - public function isRegisteredRemoved(Doctrine_Record $entity) + public function isRegisteredRemoved(Doctrine_Entity $entity) { return isset($this->_removedEntities[$entity->getOid()]); } @@ -342,7 +342,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module * Adds an entity to the pool of managed entities. * @deprecated */ - public function manage(Doctrine_Record $entity) + public function manage(Doctrine_Entity $entity) { $oid = $entity->getOid(); if ( ! isset($this->_managedEntities[$oid])) { @@ -357,7 +357,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module * @return boolean whether ot not the operation was successful * @deprecated */ - public function detach(Doctrine_Record $entity) + public function detach(Doctrine_Entity $entity) { $oid = $entity->getOid(); if ( ! isset($this->_managedEntities[$oid])) { @@ -386,7 +386,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module * the entity in question is already managed. * @throws Doctrine_Connection_Exception If the entity has no (database) identity. */ - public function registerIdentity(Doctrine_Record $entity) + public function registerIdentity(Doctrine_Entity $entity) { $idHash = $this->getIdentifierHash($entity->identifier()); if ( ! $idHash) { @@ -406,7 +406,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module $this->_identityMap[$entityName] = array(); } - public function unregisterIdentity(Doctrine_Record $entity) + public function unregisterIdentity(Doctrine_Entity $entity) { $idHash = $this->getIdentifierHash($entity->identifier()); if ( ! $idHash) { @@ -443,10 +443,10 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module /** * Checks whether an entity is registered in the identity map. * - * @param Doctrine_Record $entity + * @param Doctrine_Entity $entity * @return boolean */ - public function contains(Doctrine_Record $entity) + public function contains(Doctrine_Entity $entity) { $id = implode(' ', $entity->identifier()); if ( ! $id) { diff --git a/lib/Doctrine/Data.php b/lib/Doctrine/Data.php index 6b850937e..78e12b076 100644 --- a/lib/Doctrine/Data.php +++ b/lib/Doctrine/Data.php @@ -242,13 +242,13 @@ class Doctrine_Data /** * isRelation * - * Check if a fieldName on a Doctrine_Record is a relation, if it is we return that relationData + * Check if a fieldName on a Doctrine_Entity is a relation, if it is we return that relationData * - * @param string $Doctrine_Record + * @param string $Doctrine_Entity * @param string $fieldName * @return void */ - public function isRelation(Doctrine_Record $record, $fieldName) + public function isRelation(Doctrine_Entity $record, $fieldName) { $relations = $record->getTable()->getRelations(); @@ -267,7 +267,7 @@ class Doctrine_Data /** * purge * - * Purge all data for loaded models or for the passed array of Doctrine_Records + * Purge all data for loaded models or for the passed array of Doctrine_Entitys * * @param string $models * @return void diff --git a/lib/Doctrine/Data/Import.php b/lib/Doctrine/Data/Import.php index d06e4e58c..482e29701 100644 --- a/lib/Doctrine/Data/Import.php +++ b/lib/Doctrine/Data/Import.php @@ -289,7 +289,7 @@ class Doctrine_Data_Import extends Doctrine_Data } } - public function populateDummyRecord(Doctrine_Record $record) + public function populateDummyRecord(Doctrine_Entity $record) { $lorem = explode(' ', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Entity.php similarity index 88% rename from lib/Doctrine/Record.php rename to lib/Doctrine/Entity.php index 71706860e..be63a8509 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Entity.php @@ -1,6 +1,6 @@ * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @link www.phpdoctrine.org - * @since 1.0 - * @version $Revision$ + * @since 2.0 + * @version $Revision: 4342 $ * @todo Rename to "Entity". Split up into "Entity" and "ActiveEntity (extends Entity)"??? * @todo Remove as many methods as possible. */ -abstract class Doctrine_Record extends Doctrine_Access implements Countable, IteratorAggregate, Serializable +abstract class Doctrine_Entity extends Doctrine_Access implements Countable, IteratorAggregate, Serializable { /** * STATE CONSTANTS @@ -42,39 +42,39 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * DIRTY STATE - * a Doctrine_Record is in dirty state when its properties are changed + * a Doctrine_Entity is in dirty state when its properties are changed */ const STATE_DIRTY = 1; /** * TDIRTY STATE - * a Doctrine_Record is in transient dirty state when it is created + * a Doctrine_Entity is in transient dirty state when it is created * and some of its fields are modified but it is NOT yet persisted into database */ const STATE_TDIRTY = 2; /** * CLEAN STATE - * a Doctrine_Record is in clean state when all of its properties are loaded from the database + * a Doctrine_Entity is in clean state when all of its properties are loaded from the database * and none of its properties are changed */ const STATE_CLEAN = 3; /** * PROXY STATE - * a Doctrine_Record is in proxy state when its properties are not fully loaded + * a Doctrine_Entity is in proxy state when its properties are not fully loaded */ const STATE_PROXY = 4; /** * NEW TCLEAN - * a Doctrine_Record is in transient clean state when it is created and none of its fields are modified + * a Doctrine_Entity is in transient clean state when it is created and none of its fields are modified */ const STATE_TCLEAN = 5; /** * LOCKED STATE - * a Doctrine_Record is temporarily locked during deletes and saves + * a Doctrine_Entity is temporarily locked during deletes and saves * * This state is used internally to ensure that circular deletes * and saves will not cause infinite loops @@ -119,7 +119,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite protected $_class; /** - * + * The name of the Entity. + * + * @var string */ protected $_entityName; @@ -146,7 +148,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * The values array, aggregate values and such are mapped into this array. * - * @var array + * @var array + * @todo Remove. */ protected $_values = array(); @@ -206,15 +209,19 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @throws Doctrine_Connection_Exception if object is created using the new operator and there are no * open connections * @throws Doctrine_Record_Exception if the cleanData operation fails somehow + * @todo Remove all parameters. */ public function __construct($isNewEntry = true, array $data = array()) { $this->_entityName = get_class($this); $this->_em = Doctrine_Manager::getInstance()->getCurrentConnection(); + // future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName); $this->_class = $this->_em->getClassMetadata($this->_entityName); - $this->_oid = self::$_index++; + + // The following code inits data, id and state + // get the data array $this->_data = $data; @@ -227,24 +234,25 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if ($isNewEntry) { if ($count > count($this->_values)) { - $this->_state = Doctrine_Record::STATE_TDIRTY; + $this->_state = Doctrine_Entity::STATE_TDIRTY; } else { - $this->_state = Doctrine_Record::STATE_TCLEAN; + $this->_state = Doctrine_Entity::STATE_TCLEAN; } // set the default values for this record $this->assignDefaultValues(); } else { // TODO: registerClean() on UnitOfWork - $this->_state = Doctrine_Record::STATE_CLEAN; + $this->_state = Doctrine_Entity::STATE_CLEAN; if ($count < $this->_class->getColumnCount()) { - $this->_state = Doctrine_Record::STATE_PROXY; + $this->_state = Doctrine_Entity::STATE_PROXY; } } + //-- self::$_useAutoAccessorOverride = false; // @todo read from attribute the first time - $this->_em->manage($this); - $this->construct(); + $this->_em->manage($this); // @todo Remove + $this->construct(); // @todo Remove } /** @@ -450,7 +458,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite { if ($stack !== null) { if ( ! ($stack instanceof Doctrine_Validator_ErrorStack)) { - throw new Doctrine_Record_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.'); + throw new Doctrine_Entity_Exception('Argument should be an instance of Doctrine_Validator_ErrorStack.'); } $this->_errorStack = $stack; } else { @@ -464,7 +472,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * * @param boolean $overwrite whether or not to overwrite the already set values * @return boolean - * @todo Maybe better placed in the Mapper? + * @todo Job of EntityManager. */ public function assignDefaultValues($overwrite = false) { @@ -481,7 +489,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if ($value === Doctrine_Null::$INSTANCE || $overwrite) { $this->_data[$column] = $default; $this->_modified[] = $column; - $this->_state = Doctrine_Record::STATE_TDIRTY; + $this->_state = Doctrine_Entity::STATE_TDIRTY; } } } @@ -494,7 +502,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * * @param array $data data array to be cleaned * @return array $tmp values cleaned from data - * @todo Maybe better placed in the Mapper? + * @todo Remove. Should not be necessary. Slows down instantiation. */ public function cleanData(&$data) { @@ -601,7 +609,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->_data = array_merge($this->_data, $this->_id); foreach ($this->_data as $k => $v) { - if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') { + if ($v instanceof Doctrine_Entity && $this->_class->getTypeOf($k) != 'object') { unset($vars['_data'][$k]); } else if ($v === Doctrine_Null::$INSTANCE) { unset($vars['_data'][$k]); @@ -632,7 +640,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * Reconstructs the entity from it's serialized form. * This method is automatically called everytime the entity is unserialized. * - * @param string $serialized Doctrine_Record as serialized string + * @param string $serialized Doctrine_Entity as serialized string * @throws Doctrine_Record_Exception if the cleanData operation fails somehow * @return void */ @@ -687,7 +695,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * returns / assigns the state of this record * * @param integer|string $state if set, this method tries to set the record state to $state - * @see Doctrine_Record::STATE_* constants + * @see Doctrine_Entity::STATE_* constants * * @throws Doctrine_Record_State_Exception if trying to set an unknown state * @return null|integer @@ -707,7 +715,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } else if (is_string($state)) { $upper = strtoupper($state); - $const = 'Doctrine_Record::STATE_' . $upper; + $const = 'Doctrine_Entity::STATE_' . $upper; if (defined($const)) { $this->_state = constant($const); } else { @@ -715,8 +723,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } } - if ($this->_state === Doctrine_Record::STATE_TCLEAN || - $this->_state === Doctrine_Record::STATE_CLEAN) { + if ($this->_state === Doctrine_Entity::STATE_TCLEAN || + $this->_state === Doctrine_Entity::STATE_CLEAN) { $this->_modified = array(); } @@ -735,8 +743,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @throws Doctrine_Record_Exception When the refresh operation fails (when the database row * this record represents does not exist anymore) * @return boolean - * @todo Logic is better placed in the Mapper. Just forward to the mapper. - * @todo ActiveRecord method. + * @todo Implementation to EntityManager. + * @todo ActiveEntity method. */ public function refresh($deep = false) { @@ -773,7 +781,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->_extractIdentifier(); - $this->_state = Doctrine_Record::STATE_CLEAN; + $this->_state = Doctrine_Entity::STATE_CLEAN; return $this; } @@ -785,9 +793,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @param string $name name of a related component. * if set, this method only refreshes the specified related component * - * @return Doctrine_Record this object - * @todo Logic is better placed in the Mapper. Just forward to the mapper. - * @todo ActiveRecord method. + * @return Doctrine_Entity this object + * @todo Implementation to EntityManager. + * @todo ActiveEntity method. */ public function refreshRelated($name = null) { @@ -823,7 +831,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } /** - * + * @todo Remove. */ public function getValues() { @@ -831,25 +839,136 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } /** - * rawGet - * returns the value of a property, if the property is not yet loaded - * this method does NOT load it + * Gets the value of a field (regular field or reference). + * If the property is not yet loaded this method does NOT load it. + * + * NOTE: Use of this method from outside the scope of an extending class + * is strongly discouraged. * * @param $name name of the property - * @throws Doctrine_Record_Exception if trying to get an unknown property + * @throws Doctrine_Entity_Exception if trying to get an unknown field * @return mixed */ public function rawGet($fieldName) { - if ( ! isset($this->_data[$fieldName])) { - throw new Doctrine_Record_Exception('Unknown property '. $fieldName); + if (isset($this->_data[$fieldName])) { + return $this->rawGetField($fieldName); + } else if (isset($this->_references[$fieldName])) { + return $this->rawGetReference($fieldName); + } else { + throw Doctrine_Entity_Exception::unknownField($fieldName); } + } + + /** + * Gets the value of a field. + * + * NOTE: Use of this method from outside the scope of an extending class + * is strongly discouraged. This method does NOT check whether the field + * exists. + * + * @param string $fieldName + * @return mixed + */ + public function rawGetField($fieldName) + { if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) { return null; } - return $this->_data[$fieldName]; } + + /** + * Sets the value of a field. + * + * NOTE: Use of this method from outside the scope of an extending class + * is strongly discouraged. This method does NOT check whether the field + * exists. + * + * @param string $fieldName + * @param mixed $value + */ + public function rawSetField($fieldName, $value) + { + $this->_data[$fieldName] = $value; + } + + /** + * Gets a reference to another Entity. + * + * NOTE: Use of this method from outside the scope of an extending class + * is strongly discouraged. This method does NOT check whether the reference + * exists. + * + * @param unknown_type $fieldName + */ + public function rawGetReference($fieldName) + { + if ($this->_references[$fieldName] === Doctrine_Null::$INSTANCE) { + return null; + } + return $this->_references[$fieldName]; + } + + /** + * Sets a reference to another Entity. + * + * NOTE: Use of this method from outside the scope of an extending class + * is strongly discouraged. + * + * @param unknown_type $fieldName + * @param unknown_type $value + * @todo Refactor. What about composite keys? + */ + public function rawSetReference($name, $value) + { + if ($value === Doctrine_Null::$INSTANCE) { + $this->_references[$name] = $value; + return; + } + + $rel = $this->_class->getRelation($name); + + // one-to-many or one-to-one relation + if ($rel instanceof Doctrine_Relation_ForeignKey || + $rel instanceof Doctrine_Relation_LocalKey) { + if ( ! $rel->isOneToOne()) { + // one-to-many relation found + if ( ! $value instanceof Doctrine_Collection) { + throw Doctrine_Entity_Exception::invalidValueForOneToManyReference(); + } + if (isset($this->_references[$name])) { + $this->_references[$name]->setData($value->getData()); + return $this; + } + } else { + $relatedTable = $value->getTable(); + $foreignFieldName = $rel->getForeignFieldName(); + $localFieldName = $rel->getLocalFieldName(); + + // one-to-one relation found + if ( ! ($value instanceof Doctrine_Entity)) { + throw Doctrine_Entity_Exception::invalidValueForOneToOneReference(); + } + if ($rel instanceof Doctrine_Relation_LocalKey) { + $idFieldNames = $value->getTable()->getIdentifier(); + if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) { + $this->set($localFieldName, $value->rawGet($foreignFieldName), false); + } else { + $this->set($localFieldName, $value, false); + } + } else { + $value->set($foreignFieldName, $this, false); + } + } + } else if ($rel instanceof Doctrine_Relation_Association) { + if ( ! ($value instanceof Doctrine_Collection)) { + throw Doctrine_Entity_Exception::invalidValueForManyToManyReference(); + } + } + + $this->_references[$name] = $value; + } /** * load @@ -860,10 +979,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite */ public function load() { - // only load the data from database if the Doctrine_Record is in proxy state - if ($this->_state == Doctrine_Record::STATE_PROXY) { + // only load the data from database if the Doctrine_Entity is in proxy state + if ($this->_state == Doctrine_Entity::STATE_PROXY) { $this->refresh(); - $this->_state = Doctrine_Record::STATE_CLEAN; + $this->_state = Doctrine_Entity::STATE_CLEAN; return true; } return false; @@ -966,7 +1085,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * set - * method for altering properties and Doctrine_Record references + * method for altering properties and Doctrine_Entity references * if the load parameter is set to false this method will not try to load uninitialized record data * * @param mixed $name name of the property or reference @@ -976,12 +1095,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @throws Doctrine_Record_Exception if trying to set a value for unknown property / related component * @throws Doctrine_Record_Exception if trying to set a value of wrong type for related component * - * @return Doctrine_Record + * @return Doctrine_Entity */ public function set($fieldName, $value, $load = true) { if (isset($this->_data[$fieldName])) { - if ($value instanceof Doctrine_Record) { + if ($value instanceof Doctrine_Entity) { $type = $this->_class->getTypeOf($fieldName); // FIXME: composite key support $ids = $value->identifier(); @@ -1012,17 +1131,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } switch ($this->_state) { - case Doctrine_Record::STATE_CLEAN: - $this->_state = Doctrine_Record::STATE_DIRTY; + case Doctrine_Entity::STATE_CLEAN: + $this->_state = Doctrine_Entity::STATE_DIRTY; break; - case Doctrine_Record::STATE_TCLEAN: - $this->_state = Doctrine_Record::STATE_TDIRTY; + case Doctrine_Entity::STATE_TCLEAN: + $this->_state = Doctrine_Entity::STATE_TDIRTY; break; } } } else { try { - $this->_coreSetRelated($fieldName, $value); + $this->rawSetReference($fieldName, $value); } catch (Doctrine_Relation_Exception $e) { //echo $e->getTraceAsString(); //echo "

"; @@ -1035,67 +1154,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } } - /** - * Sets a related component. - * @todo Refactor. What about composite keys? - */ - private function _coreSetRelated($name, $value) - { - if ($value === Doctrine_Null::$INSTANCE) { - $this->_references[$name] = $value; - return; - } - - $rel = $this->_class->getRelation($name); - - // one-to-many or one-to-one relation - if ($rel instanceof Doctrine_Relation_ForeignKey || - $rel instanceof Doctrine_Relation_LocalKey) { - if ( ! $rel->isOneToOne()) { - // one-to-many relation found - if ( ! $value instanceof Doctrine_Collection) { - throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second" - . " argument should be an instance of Doctrine_Collection when" - . " setting one-to-many references."); - } - if (isset($this->_references[$name])) { - $this->_references[$name]->setData($value->getData()); - return $this; - } - } else { - if ($value !== Doctrine_Null::$INSTANCE) { - $relatedTable = $value->getTable(); - $foreignFieldName = $rel->getForeignFieldName(); - $localFieldName = $rel->getLocalFieldName(); - - // one-to-one relation found - if ( ! ($value instanceof Doctrine_Record)) { - throw new Doctrine_Record_Exception("Couldn't call Doctrine::set()," - . " second argument should be an instance of Doctrine_Record" - . " or Doctrine_Null when setting one-to-one references."); - } - if ($rel instanceof Doctrine_Relation_LocalKey) { - $idFieldNames = $value->getTable()->getIdentifier(); - if ( ! empty($foreignFieldName) && $foreignFieldName != $idFieldNames[0]) { - $this->set($localFieldName, $value->rawGet($foreignFieldName), false); - } else { - $this->set($localFieldName, $value, false); - } - } else { - $value->set($foreignFieldName, $this, false); - } - } - } - } else if ($rel instanceof Doctrine_Relation_Association) { - // join table relation found - if ( ! ($value instanceof Doctrine_Collection)) { - throw new Doctrine_Record_Exception("Couldn't call Doctrine::set(), second argument should be an instance of Doctrine_Collection when setting many-to-many references."); - } - } - - $this->_references[$name] = $value; - } - /** * contains * @@ -1132,7 +1190,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if (isset($this->_data[$fieldName])) { $this->_data[$fieldName] = array(); } else if (isset($this->_references[$fieldName])) { - if ($this->_references[$fieldName] instanceof Doctrine_Record) { + if ($this->_references[$fieldName] instanceof Doctrine_Entity) { // todo: delete related record when saving $this $this->_references[$fieldName] = Doctrine_Null::$INSTANCE; } else if ($this->_references[$fieldName] instanceof Doctrine_Collection) { @@ -1157,7 +1215,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * Tries to save the object and all its related objects. - * In contrast to Doctrine_Record::save(), this method does not + * In contrast to Doctrine_Entity::save(), this method does not * throw an exception when validation fails but returns TRUE on * success or FALSE on failure. * @@ -1269,7 +1327,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $dataSet[$field] = $this->_class->enumIndex($field, $this->_data[$field]); break; default: - if ($this->_data[$field] instanceof Doctrine_Record) { + if ($this->_data[$field] instanceof Doctrine_Entity) { // FIXME: composite key support $ids = $this->_data[$field]->identifier(); $id = count($ids) > 0 ? array_pop($ids) : null; @@ -1353,9 +1411,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } } - // [FIX] Prevent mapped Doctrine_Records from being displayed fully + // [FIX] Prevent mapped Doctrine_Entitys from being displayed fully foreach ($this->_values as $key => $value) { - if ($value instanceof Doctrine_Record) { + if ($value instanceof Doctrine_Entity) { $a[$key] = $value->toArray($deep, $prefixKey); } else { $a[$key] = $value; @@ -1410,14 +1468,14 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * synchronizeFromArray - * synchronizes a Doctrine_Record and its relations with data from an array + * synchronizes a Doctrine_Entity and its relations with data from an array * - * it expects an array representation of a Doctrine_Record similar to the return + * it expects an array representation of a Doctrine_Entity similar to the return * value of the toArray() method. If the array contains relations it will create * those that don't exist, update the ones that do, and delete the ones missing - * on the array but available on the Doctrine_Record + * on the array but available on the Doctrine_Entity * - * @param array $array representation of a Doctrine_Record + * @param array $array representation of a Doctrine_Entity * @todo ActiveRecord method. */ public function synchronizeFromArray(array $array) @@ -1480,8 +1538,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite */ public function exists() { - return ($this->_state !== Doctrine_Record::STATE_TCLEAN && - $this->_state !== Doctrine_Record::STATE_TDIRTY); + return ($this->_state !== Doctrine_Entity::STATE_TCLEAN && + $this->_state !== Doctrine_Entity::STATE_TDIRTY); } /** @@ -1513,8 +1571,8 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite */ public function isDirty() { - return ($this->_state === Doctrine_Record::STATE_DIRTY || - $this->_state === Doctrine_Record::STATE_TDIRTY); + return ($this->_state === Doctrine_Entity::STATE_DIRTY || + $this->_state === Doctrine_Entity::STATE_TDIRTY); } /** @@ -1526,12 +1584,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite */ public function isModified() { - return ($this->_state === Doctrine_Record::STATE_DIRTY || - $this->_state === Doctrine_Record::STATE_TDIRTY); + return ($this->_state === Doctrine_Entity::STATE_DIRTY || + $this->_state === Doctrine_Entity::STATE_TDIRTY); } /** - * method for checking existence of properties and Doctrine_Record references + * method for checking existence of properties and Doctrine_Entity references * * @param mixed $name name of the property or reference * @return boolean @@ -1572,7 +1630,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite /** * Creates a copy of the entity. * - * @return Doctrine_Record + * @return Doctrine_Entity * @todo ActiveRecord method. Implementation to EntityManager. */ public function copy($deep = true) @@ -1621,11 +1679,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if ($id === false) { $this->_id = array(); $this->_data = $this->cleanData($this->_data); - $this->_state = Doctrine_Record::STATE_TCLEAN; + $this->_state = Doctrine_Entity::STATE_TCLEAN; $this->_modified = array(); } else if ($id === true) { $this->_extractIdentifier(true); - $this->_state = Doctrine_Record::STATE_CLEAN; + $this->_state = Doctrine_Entity::STATE_CLEAN; $this->_modified = array(); } else { if (is_array($id)) { @@ -1639,7 +1697,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $this->_id[$name] = $id; $this->_data[$name] = $id; } - $this->_state = Doctrine_Record::STATE_CLEAN; + $this->_state = Doctrine_Entity::STATE_CLEAN; $this->_modified = array(); } } @@ -1731,7 +1789,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * @param string|array $callback valid callback * @param string $column column name * @param mixed arg1 ... argN optional callback arguments - * @return Doctrine_Record + * @return Doctrine_Entity * @todo Really needed/used? If not, remove. * @todo ActiveRecord method. (if at all) */ @@ -1779,7 +1837,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * * @throws Doctrine_Record_Exception if given version does not exist * @param integer $version an integer > 1 - * @return Doctrine_Record this object + * @return Doctrine_Entity this object * @todo Should go to the Versionable plugin. */ public function revert($version) @@ -1813,7 +1871,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * * @param string $alias related component alias * @param array $ids the identifiers of the related records - * @return Doctrine_Record this object + * @return Doctrine_Entity this object * @todo ActiveRecord method. */ public function unlink($alias, $ids = array()) @@ -1868,7 +1926,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite * * @param string $alias related component alias * @param array $ids the identifiers of the related records - * @return Doctrine_Record this object + * @return Doctrine_Entity this object * @todo ActiveRecord method. */ public function link($alias, array $ids) @@ -2001,8 +2059,17 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite return $this->_class; } + /** + * Enter description here... + * + * @return unknown + */ public function getEntityManager() { + if ( ! $this->_em) { + $this->_em = Doctrine_Manager::getInstance()->getCurrentConnection(); + // future: $this->_em = Doctrine_EntityManager::getManagerForEntity($this->_entityName); + } return $this->_em; } diff --git a/lib/Doctrine/Entity/Exception.php b/lib/Doctrine/Entity/Exception.php new file mode 100644 index 000000000..11883bc3e --- /dev/null +++ b/lib/Doctrine/Entity/Exception.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/lib/Doctrine/EntityRepository.php b/lib/Doctrine/EntityRepository.php index d4e66ebe8..5aec5c064 100644 --- a/lib/Doctrine/EntityRepository.php +++ b/lib/Doctrine/EntityRepository.php @@ -63,11 +63,9 @@ class Doctrine_EntityRepository } /** - * clear - * clears the first level cache (identityMap) + * Clears the repository, causing all managed entities to become detached. * * @return void - * @todo what about a more descriptive name? clearIdentityMap? */ public function clear() { @@ -77,9 +75,9 @@ class Doctrine_EntityRepository /** * Finds an entity by its primary key. * - * @param $id database row id - * @param int $hydrationMode Doctrine::HYDRATE_ARRAY or Doctrine::HYDRATE_RECORD - * @return mixed Array or Doctrine_Record or false if no result + * @param $id The identifier. + * @param int $hydrationMode The hydration mode to use. + * @return mixed Array or Doctrine_Entity or false if no result * @todo Remove. Move to EntityRepository. */ public function find($id, $hydrationMode = null) diff --git a/lib/Doctrine/EventListener/Chain.php b/lib/Doctrine/EventListener/Chain.php index b52521794..4b11d3a9e 100644 --- a/lib/Doctrine/EventListener/Chain.php +++ b/lib/Doctrine/EventListener/Chain.php @@ -96,12 +96,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E /** * onLoad - * an event invoked when Doctrine_Record is being loaded from database + * an event invoked when Doctrine_Entity is being loaded from database * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return void */ - public function onLoad(Doctrine_Record $record) + public function onLoad(Doctrine_Entity $record) { foreach ($this->_listeners as $listener) { $listener->onLoad($record); @@ -110,13 +110,13 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E /** * onPreLoad - * an event invoked when Doctrine_Record is being loaded + * an event invoked when Doctrine_Entity is being loaded * from database but not yet initialized * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return void */ - public function onPreLoad(Doctrine_Record $record) + public function onPreLoad(Doctrine_Entity $record) { foreach ($this->_listeners as $listener) { $listener->onPreLoad($record); @@ -125,12 +125,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E /** * onSleep - * an event invoked when Doctrine_Record is serialized + * an event invoked when Doctrine_Entity is serialized * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return void */ - public function onSleep(Doctrine_Record $record) + public function onSleep(Doctrine_Entity $record) { foreach ($this->_listeners as $listener) { $listener->onSleep($record); @@ -139,12 +139,12 @@ class Doctrine_EventListener_Chain extends Doctrine_Access implements Doctrine_E /** * onWakeUp - * an event invoked when Doctrine_Record is unserialized + * an event invoked when Doctrine_Entity is unserialized * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return void */ - public function onWakeUp(Doctrine_Record $record) + public function onWakeUp(Doctrine_Entity $record) { foreach ($this->_listeners as $listener) { $listener->onWakeUp($record); diff --git a/lib/Doctrine/Export.php b/lib/Doctrine/Export.php index 889252350..6a35ae8d9 100644 --- a/lib/Doctrine/Export.php +++ b/lib/Doctrine/Export.php @@ -1030,13 +1030,13 @@ class Doctrine_Export extends Doctrine_Connection_Module /** * exportSchema - * method for exporting Doctrine_Record classes to a schema + * method for exporting Doctrine_Entity classes to a schema * * if the directory parameter is given this method first iterates * recursively trhough the given directory in order to find any model classes * * Then it iterates through all declared classes and creates tables for the ones - * that extend Doctrine_Record and are not abstract classes + * that extend Doctrine_Entity and are not abstract classes * * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * occurred during the create table operation @@ -1060,7 +1060,7 @@ class Doctrine_Export extends Doctrine_Connection_Module * FIXME: This method is a big huge hack. The sql needs to be executed in the correct order. I have some stupid logic to * make sure they are in the right order. * - * method for exporting Doctrine_Record classes to a schema + * method for exporting Doctrine_Entity classes to a schema * * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * occurred during the create table operation @@ -1133,7 +1133,7 @@ class Doctrine_Export extends Doctrine_Connection_Module /** * exportClassesSql - * method for exporting Doctrine_Record classes to a schema + * method for exporting Doctrine_Entity classes to a schema * * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * occurred during the create table operation @@ -1244,13 +1244,13 @@ class Doctrine_Export extends Doctrine_Connection_Module /** * exportSql - * returns the sql for exporting Doctrine_Record classes to a schema + * returns the sql for exporting Doctrine_Entity classes to a schema * * if the directory parameter is given this method first iterates * recursively trhough the given directory in order to find any model classes * * Then it iterates through all declared classes and creates tables for the ones - * that extend Doctrine_Record and are not abstract classes + * that extend Doctrine_Entity and are not abstract classes * * @throws Doctrine_Connection_Exception if some error other than Doctrine::ERR_ALREADY_EXISTS * occurred during the create table operation diff --git a/lib/Doctrine/Export/Schema.php b/lib/Doctrine/Export/Schema.php index 3749ff775..1823ef9cf 100644 --- a/lib/Doctrine/Export/Schema.php +++ b/lib/Doctrine/Export/Schema.php @@ -52,7 +52,7 @@ class Doctrine_Export_Schema $array = array(); - $parent = new ReflectionClass('Doctrine_Record'); + $parent = new ReflectionClass('Doctrine_Entity'); $sql = array(); $fks = array(); diff --git a/lib/Doctrine/File.php b/lib/Doctrine/File.php index 7021c95c7..946b59118 100644 --- a/lib/Doctrine/File.php +++ b/lib/Doctrine/File.php @@ -30,7 +30,7 @@ * @link www.phpdoctrine.org * @since 1.0 */ -class Doctrine_File extends Doctrine_Record +class Doctrine_File extends Doctrine_Entity { public function setTableDefinition() { diff --git a/lib/Doctrine/File/Index.php b/lib/Doctrine/File/Index.php index daeef0ffe..a0b302d3e 100644 --- a/lib/Doctrine/File/Index.php +++ b/lib/Doctrine/File/Index.php @@ -30,7 +30,7 @@ * @link www.phpdoctrine.org * @since 1.0 */ -class Doctrine_File_Index extends Doctrine_Record +class Doctrine_File_Index extends Doctrine_Entity { public function setTableDefinition() { diff --git a/lib/Doctrine/Hydrator.php b/lib/Doctrine/Hydrator.php index d3b53362e..239f166da 100644 --- a/lib/Doctrine/Hydrator.php +++ b/lib/Doctrine/Hydrator.php @@ -58,22 +58,27 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract * ) * @return mixed The created object/array graph. */ - public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null) + public function hydrateResultSet($parserResult) { - if ($hydrationMode === null) { + if ($parserResult->getHydrationMode() === null) { $hydrationMode = $this->_hydrationMode; + } else { + $hydrationMode = $parserResult->getHydrationMode(); } + $stmt = $parserResult->getDatabaseStatement(); + if ($hydrationMode == Doctrine::HYDRATE_NONE) { return $stmt->fetchAll(PDO::FETCH_NUM); } - $this->_tableAliases = $tableAliases; + $this->_tableAliases = $parserResult->getTableToClassAliasMap(); + $this->_queryComponents = $parserResult->getQueryComponents(); if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { $driver = new Doctrine_Hydrator_ArrayDriver(); } else { - $driver = new Doctrine_Hydrator_RecordDriver(); + $driver = new Doctrine_Hydrator_RecordDriver($this->_em); } $event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null); @@ -294,7 +299,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract end($coll); $prev[$dqlAlias] =& $coll[key($coll)]; } - } else if ($coll instanceof Doctrine_Record) { + } else if ($coll instanceof Doctrine_Entity) { $prev[$dqlAlias] = $coll; } else if (count($coll) > 0) { $prev[$dqlAlias] = $coll->getLast(); diff --git a/lib/Doctrine/Hydrator/Abstract.php b/lib/Doctrine/Hydrator/Abstract.php index 7b54f074d..b474f5a43 100644 --- a/lib/Doctrine/Hydrator/Abstract.php +++ b/lib/Doctrine/Hydrator/Abstract.php @@ -55,14 +55,17 @@ abstract class Doctrine_Hydrator_Abstract protected $_hydrationMode = Doctrine::HYDRATE_RECORD; protected $_nullObject; + + protected $_em; /** * constructor * * @param Doctrine_Connection|null $connection */ - public function __construct() + public function __construct(Doctrine_Connection $em) { + $this->_em = $em; $this->_nullObject = Doctrine_Null::$INSTANCE; } @@ -156,6 +159,6 @@ abstract class Doctrine_Hydrator_Abstract * @param mixed $stmt * @return array */ - abstract public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null); + abstract public function hydrateResultSet($parserResult); } diff --git a/lib/Doctrine/Hydrator/ArrayDriver.php b/lib/Doctrine/Hydrator/ArrayDriver.php index e293e1901..1a4adb8cc 100644 --- a/lib/Doctrine/Hydrator/ArrayDriver.php +++ b/lib/Doctrine/Hydrator/ArrayDriver.php @@ -33,6 +33,7 @@ */ class Doctrine_Hydrator_ArrayDriver { + /** * */ @@ -73,6 +74,52 @@ class Doctrine_Hydrator_ArrayDriver } } + public function addRelatedIndexedElement(array &$entity1, $property, array &$entity2, + $indexField) + { + $entity1[$property][$entity2[$indexField]] = $entity2; + } + + public function addRelatedElement(array &$entity1, $property, array &$entity2) + { + $entity1[$property][] = $entity2; + } + + public function setRelatedElement(array &$entity1, $property, &$entity2) + { + $entity1[$property] = $entity2; + } + + public function isIndexKeyInUse(array &$entity, $assocField, $indexField) + { + return isset($entity[$assocField][$indexField]); + } + + public function isFieldSet(array &$entity, $field) + { + return isset($entity[$field]); + } + + public function getFieldValue(array &$entity, $field) + { + return $entity[$field]; + } + + public function &getReferenceValue(array &$entity, $field) + { + return $entity[$field]; + } + + public function addElementToIndexedCollection(array &$coll, array &$entity, $keyField) + { + $coll[$entity[$keyField]] = $entity; + } + + public function addElementToCollection(array &$coll, array &$entity) + { + $coll[] = $entity; + } + /** * */ diff --git a/lib/Doctrine/Hydrator/RecordDriver.php b/lib/Doctrine/Hydrator/RecordDriver.php index 106f5b364..4d34434f6 100644 --- a/lib/Doctrine/Hydrator/RecordDriver.php +++ b/lib/Doctrine/Hydrator/RecordDriver.php @@ -36,16 +36,17 @@ class Doctrine_Hydrator_RecordDriver { /** Collections initialized by the driver */ protected $_collections = array(); - /** Mappers */ - protected $_mappers = array(); /** Memory for initialized relations */ private $_initializedRelations = array(); /** Null object */ private $_nullObject; + /** The EntityManager */ + private $_em; - public function __construct() + public function __construct(Doctrine_Connection $em) { $this->_nullObject = Doctrine_Null::$INSTANCE; + $this->_em = $em; } public function getElementCollection($component) @@ -68,15 +69,15 @@ class Doctrine_Hydrator_RecordDriver } } - public function initRelatedCollection(Doctrine_Record $record, $name) + public function initRelatedCollection(Doctrine_Entity $entity, $name) { - if ( ! isset($this->_initializedRelations[$record->getOid()][$name])) { - $relation = $record->getClassMetadata()->getRelation($name); + if ( ! isset($this->_initializedRelations[$entity->getOid()][$name])) { + $relation = $entity->getClassMetadata()->getRelation($name); $relatedClass = $relation->getTable(); $coll = $this->getElementCollection($relatedClass->getClassName()); - $coll->setReference($record, $relation); - $record[$name] = $coll; - $this->_initializedRelations[$record->getOid()][$name] = true; + $coll->setReference($entity, $relation); + $entity->rawSetReference($name, $coll); + $this->_initializedRelations[$entity->getOid()][$name] = true; } } @@ -92,14 +93,54 @@ class Doctrine_Hydrator_RecordDriver public function getElement(array $data, $className) { - $className = $this->_getClassnameToReturn($data, $className); - if ( ! isset($this->_mappers[$className])) { - $this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className); - } - - $record = $this->_mappers[$className]->getRecord($data); - - return $record; + return $this->_em->createEntity2($className, $data); + } + + public function addRelatedIndexedElement(Doctrine_Entity $entity1, $property, + Doctrine_Entity $entity2, $indexField) + { + $entity1->rawGetReference($property)->add($entity2, $entity2->rawGetField($indexField)); + } + + public function addRelatedElement(Doctrine_Entity $entity1, $property, + Doctrine_Entity $entity2) + { + $entity1->rawGetReference($property)->add($entity2); + } + + public function setRelatedElement(Doctrine_Entity $entity1, $property, $entity2) + { + $entity1->rawSetReference($property, $entity2); + } + + public function isIndexKeyInUse(Doctrine_Entity $entity, $assocField, $indexField) + { + return $entity->rawGetReference($assocField)->contains($indexField); + } + + public function isFieldSet(Doctrine_Entity $entity, $field) + { + return $entity->contains($field); + } + + public function getFieldValue(Doctrine_Entity $entity, $field) + { + return $entity->rawGetField($field); + } + + public function getReferenceValue(Doctrine_Entity $entity, $field) + { + return $entity->rawGetReference($field); + } + + public function addElementToIndexedCollection($coll, $entity, $keyField) + { + $coll->add($entity, $entity->rawGetField($keyField)); + } + + public function addElementToCollection($coll, $entity) + { + $coll->add($entity); } public function flush() @@ -109,35 +150,8 @@ class Doctrine_Hydrator_RecordDriver $coll->takeSnapshot(); } $this->_collections = array(); - $this->_mappers = array(); $this->_initializedRelations = array(); } - /** - * Check the dataset for a discriminator column to determine the correct - * class to instantiate. If no discriminator column is found, the given - * classname will be returned. - * - * @return string The name of the class to instantiate. - * @todo Can be optimized performance-wise. - */ - protected function _getClassnameToReturn(array $data, $className) - { - if ( ! isset($this->_mappers[$className])) { - $this->_mappers[$className] = Doctrine_Manager::getInstance()->getMapper($className); - } - - $discCol = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorColumn'); - if ( ! $discCol) { - return $className; - } - - $discMap = $this->_mappers[$className]->getClassMetadata()->getInheritanceOption('discriminatorMap'); - - if (isset($data[$discCol], $discMap[$data[$discCol]])) { - return $discMap[$data[$discCol]]; - } else { - return $className; - } - } + } diff --git a/lib/Doctrine/HydratorNew.php b/lib/Doctrine/HydratorNew.php index 925a29af8..3f2afa132 100644 --- a/lib/Doctrine/HydratorNew.php +++ b/lib/Doctrine/HydratorNew.php @@ -77,27 +77,32 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract * ) * @return mixed The created object/array graph. */ - public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null) + public function hydrateResultSet($parserResult) { - if ($hydrationMode === null) { + if ($parserResult->getHydrationMode() === null) { $hydrationMode = $this->_hydrationMode; + } else { + $hydrationMode = $parserResult->getHydrationMode(); } + $stmt = $parserResult->getDatabaseStatement(); + if ($hydrationMode == Doctrine::HYDRATE_NONE) { return $stmt->fetchAll(PDO::FETCH_NUM); } - $this->_tableAliases = $tableAliases; + $this->_tableAliases = $parserResult->getTableToClassAliasMap(); + $this->_queryComponents = $parserResult->getQueryComponents(); if ($hydrationMode == Doctrine::HYDRATE_ARRAY) { $driver = new Doctrine_Hydrator_ArrayDriver(); } else { - $driver = new Doctrine_Hydrator_RecordDriver(); + $driver = new Doctrine_Hydrator_RecordDriver($this->_em); } $event = new Doctrine_Event(null, Doctrine_Event::HYDRATE, null); - //$s = microtime(true); + $s = microtime(true); // Used variables during hydration reset($this->_queryComponents); @@ -120,7 +125,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract $idTemplate = array(); // Holds the resulting hydrated data structure - if ($this->_isResultMixed) { + if ($parserResult->isMixedQuery()) { $result = array(); } else { $result = $driver->getElementCollection($rootComponentName); @@ -171,21 +176,25 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract // do we need to index by a custom field? if ($field = $this->_getCustomIndexField($rootAlias)) { - if (isset($result[$field])) { + // TODO: must be checked in the parser. fields used in INDEXBY + // must be a) the primary key or b) unique & notnull + /*if (isset($result[$field])) { throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping(); } else if ( ! isset($element[$field])) { throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field); - } - if ($this->_isResultMixed) { - $result[] = array($element[$field] => $element); + }*/ + if ($parserResult->isMixedQuery()) { + $result[] = array( + $driver->getFieldValue($element, $field) => $element + ); } else { - $result[$element[$field]] = $element; + $driver->addElementToIndexedCollection($result, $element, $field); } } else { - if ($this->_isResultMixed) { + if ($parserResult->isMixedQuery()) { $result[] = array($element); } else { - $result[] = $element; + $driver->addElementToCollection($result, $element); } } $identifierMap[$rootAlias][$id[$rootAlias]] = $driver->getLastKey($result); @@ -223,7 +232,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract $path = $parent . '.' . $dqlAlias; // pick the right element that will get the associated element attached - if ($this->_isResultMixed && $parent == $rootAlias) { + if ($parserResult->isMixedQuery() && $parent == $rootAlias) { $key = key(reset($resultPointers)); // TODO: Exception if $key === null ? $baseElement =& $resultPointers[$parent][$key]; @@ -248,41 +257,44 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract //-- if ($field = $this->_getCustomIndexField($dqlAlias)) { - // TODO: we should check this earlier. Fields used in INDEXBY - // must be unique. Then this can be removed here. - if (isset($baseElement[$relationAlias][$field])) { + // TODO: must be checked in the parser. fields used in INDEXBY + // must be a) the primary key or b) unique & notnull + /*if ($driver->isIndexKeyInUse($baseElement, $relationAlias, $field)) { throw Doctrine_Hydrator_Exception::nonUniqueKeyMapping(); - } else if ( ! isset($element[$field])) { + } else if ( ! $driver->isFieldSet($element, $field)) { throw Doctrine_Hydrator_Exception::nonExistantFieldUsedAsIndex($field); - } - $baseElement[$relationAlias][$element[$field]] = $element; + }*/ + $driver->addRelatedIndexedElement($baseElement, $relationAlias, $element, $field); } else { - $baseElement[$relationAlias][] = $element; + $driver->addRelatedElement($baseElement, $relationAlias, $element); } - $identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey($baseElement[$relationAlias]); + $identifierMap[$path][$id[$parent]][$id[$dqlAlias]] = $driver->getLastKey( + $driver->getReferenceValue($baseElement, $relationAlias)); } else { $index = $identifierMap[$path][$id[$parent]][$id[$dqlAlias]]; } } else if ( ! isset($baseElement[$relationAlias])) { - $baseElement[$relationAlias] = $driver->getNullPointer(); + $driver->setRelatedElement($baseElement, $relationAlias, + $driver->getNullPointer()); } } else { // x-1 relation $oneToOne = true; if ( ! isset($nonemptyComponents[$dqlAlias])) { - $baseElement[$relationAlias] = $driver->getNullPointer(); - } else if ( ! isset($baseElement[$relationAlias])) { - $baseElement[$relationAlias] = $driver->getElement($data, $componentName); + $driver->setRelatedElement($baseElement, $relationAlias, + $driver->getNullPointer()); + } else if ( ! $driver->isFieldSet($baseElement, $relationAlias)) { + $driver->setRelatedElement($baseElement, $relationAlias, + $driver->getElement($data, $componentName)); } } - if ($baseElement[$relationAlias] !== null) { - $coll =& $baseElement[$relationAlias]; + if (($coll =& $driver->getReferenceValue($baseElement, $relationAlias)) !== null) { $this->_setLastElement($resultPointers, $coll, $index, $dqlAlias, $oneToOne); } } - // append scalar values + // append scalar values to mixed result sets if (isset($scalars)) { $rowNumber = count($result) - 1; foreach ($scalars as $name => $value) { @@ -299,8 +311,8 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract $data['table']->setAttribute(Doctrine::ATTR_LOAD_REFERENCES, true); } - //$e = microtime(true); - //echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records
'; + $e = microtime(true); + echo 'Hydration took: ' . ($e - $s) . ' for '.count($result).' records' . PHP_EOL; return $result; } @@ -339,7 +351,7 @@ class Doctrine_HydratorNew extends Doctrine_Hydrator_Abstract end($coll); $resultPointers[$dqlAlias] =& $coll[key($coll)]; } - } else if ($coll instanceof Doctrine_Record) { + } else if ($coll instanceof Doctrine_Entity) { $resultPointers[$dqlAlias] = $coll; } else if (count($coll) > 0) { $resultPointers[$dqlAlias] = $coll->getLast(); diff --git a/lib/Doctrine/Import.php b/lib/Doctrine/Import.php index 11f3b0bed..6f557991e 100644 --- a/lib/Doctrine/Import.php +++ b/lib/Doctrine/Import.php @@ -190,7 +190,7 @@ class Doctrine_Import extends Doctrine_Connection_Module /** * importSchema * - * method for importing existing schema to Doctrine_Record classes + * method for importing existing schema to Doctrine_Entity classes * * @param string $directory * @param array $databases diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 28eea1e68..742dbb883 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -23,7 +23,7 @@ * class Doctrine_Import_Schema * * Different methods to import a XML schema. The logic behind using two different - * methods is simple. Some people will like the idea of producing Doctrine_Record + * methods is simple. Some people will like the idea of producing Doctrine_Entity * objects directly, which is totally fine. But in fast and growing application, * table definitions tend to be a little bit more volatile. importArr() can be used * to output a table definition in a PHP file. This file can then be stored @@ -44,7 +44,7 @@ class Doctrine_Import_Schema 'packagesPath' => '', 'generateBaseClasses' => true, 'baseClassesDirectory' => 'generated', - 'baseClassName' => 'Doctrine_Record', + 'baseClassName' => 'Doctrine_Entity', 'suffix' => '.php'); /** @@ -136,10 +136,10 @@ class Doctrine_Import_Schema /** * importSchema * - * A method to import a Schema and translate it into a Doctrine_Record object + * A method to import a Schema and translate it into a Doctrine_Entity object * * @param string $schema The file containing the XML schema - * @param string $directory The directory where the Doctrine_Record class will be written + * @param string $directory The directory where the Doctrine_Entity class will be written * @param array $models Optional array of models to import * * @return void diff --git a/lib/Doctrine/Lib.php b/lib/Doctrine/Lib.php index 7f027d4fd..71f39f9b7 100644 --- a/lib/Doctrine/Lib.php +++ b/lib/Doctrine/Lib.php @@ -36,25 +36,25 @@ class Doctrine_Lib * getRecordStateAsString * * @param integer $state the state of record - * @see Doctrine_Record::STATE_* constants + * @see Doctrine_Entity::STATE_* constants * @return string string representation of given state */ public static function getRecordStateAsString($state) { switch ($state) { - case Doctrine_Record::STATE_PROXY: + case Doctrine_Entity::STATE_PROXY: return "proxy"; break; - case Doctrine_Record::STATE_CLEAN: + case Doctrine_Entity::STATE_CLEAN: return "persistent clean"; break; - case Doctrine_Record::STATE_DIRTY: + case Doctrine_Entity::STATE_DIRTY: return "persistent dirty"; break; - case Doctrine_Record::STATE_TDIRTY: + case Doctrine_Entity::STATE_TDIRTY: return "transient dirty"; break; - case Doctrine_Record::STATE_TCLEAN: + case Doctrine_Entity::STATE_TCLEAN: return "transient clean"; break; } @@ -63,12 +63,12 @@ class Doctrine_Lib /** * getRecordAsString * - * returns a string representation of Doctrine_Record object + * returns a string representation of Doctrine_Entity object * - * @param Doctrine_Record $record + * @param Doctrine_Entity $record * @return string */ - public static function getRecordAsString(Doctrine_Record $record) + public static function getRecordAsString(Doctrine_Entity $record) { $r[] = '
';
         $r[] = 'Component  : ' . $record->getTable()->getComponentName();
diff --git a/lib/Doctrine/Locking/Manager/Pessimistic.php b/lib/Doctrine/Locking/Manager/Pessimistic.php
index 3b0b52ec4..c28397c4e 100644
--- a/lib/Doctrine/Locking/Manager/Pessimistic.php
+++ b/lib/Doctrine/Locking/Manager/Pessimistic.php
@@ -90,15 +90,15 @@ class Doctrine_Locking_Manager_Pessimistic
     }
 
     /**
-     * Obtains a lock on a {@link Doctrine_Record}
+     * Obtains a lock on a {@link Doctrine_Entity}
      *
-     * @param  Doctrine_Record $record     The record that has to be locked
+     * @param  Doctrine_Entity $record     The record that has to be locked
      * @param  mixed           $userIdent  A unique identifier of the locking user
      * @return boolean  TRUE if the locking was successful, FALSE if another user
      *                  holds a lock on this record
      * @throws Doctrine_Locking_Exception  If the locking failed due to database errors
      */
-    public function getLock(Doctrine_Record $record, $userIdent)
+    public function getLock(Doctrine_Entity $record, $userIdent)
     {
         $objectType = $record->getTable()->getComponentName();
         $key        = $record->obtainIdentifier();
@@ -160,14 +160,14 @@ class Doctrine_Locking_Manager_Pessimistic
     }
 
     /**
-     * Releases a lock on a {@link Doctrine_Record}
+     * Releases a lock on a {@link Doctrine_Entity}
      *
-     * @param  Doctrine_Record $record    The record for which the lock has to be released
+     * @param  Doctrine_Entity $record    The record for which the lock has to be released
      * @param  mixed           $userIdent The unique identifier of the locking user
      * @return boolean  TRUE if a lock was released, FALSE if no lock was released
      * @throws Doctrine_Locking_Exception If the release procedure failed due to database errors
      */
-    public function releaseLock(Doctrine_Record $record, $userIdent)
+    public function releaseLock(Doctrine_Entity $record, $userIdent)
     {
         $objectType = $record->getTable()->getComponentName();
         $key        = $record->obtainIdentifier();
@@ -235,7 +235,7 @@ class Doctrine_Locking_Manager_Pessimistic
      * Gets the identifier that identifies the owner of the lock on the given
      * record.
      *
-     * @param Doctrine_Record $lockedRecord  The record.
+     * @param Doctrine_Entity $lockedRecord  The record.
      * @return mixed The unique user identifier that identifies the owner of the lock.
      */
     public function getLockOwner($lockedRecord)
diff --git a/lib/Doctrine/Mapper.php b/lib/Doctrine/Mapper.php
index 3781c0508..5f28d6225 100644
--- a/lib/Doctrine/Mapper.php
+++ b/lib/Doctrine/Mapper.php
@@ -68,6 +68,8 @@ class Doctrine_Mapper
      * A list of registered entity listeners.
      */
     private $_entityListeners = array();
+    
+    private $_dataTemplate = array();
 
 
     /**
@@ -118,7 +120,7 @@ class Doctrine_Mapper
      *
      * @param $array             an array where keys are field names and
      *                           values representing field values
-     * @return Doctrine_Record   the created record object
+     * @return Doctrine_Entity   the created record object
      */
     public function create(array $array = array()) 
     {
@@ -146,7 +148,7 @@ class Doctrine_Mapper
         return false;
     }
     
-    public function notifyEntityListeners(Doctrine_Record $entity, $callback, $eventType)
+    public function notifyEntityListeners(Doctrine_Entity $entity, $callback, $eventType)
     {
         if ($this->_entityListeners) {
             $event = new Doctrine_Event($entity, $eventType);
@@ -156,7 +158,7 @@ class Doctrine_Mapper
         }
     }
     
-    public function detach(Doctrine_Record $entity)
+    public function detach(Doctrine_Entity $entity)
     {
         return $this->_conn->unitOfWork->detach($entity);
     }
@@ -192,11 +194,11 @@ class Doctrine_Mapper
      * addRecord
      * adds a record to identity map
      *
-     * @param Doctrine_Record $record       record to be added
+     * @param Doctrine_Entity $record       record to be added
      * @return boolean
      * @todo Better name? registerRecord? Move elsewhere to the new location of the identity maps.
      */
-    public function addRecord(Doctrine_Record $record)
+    public function addRecord(Doctrine_Entity $record)
     {
         if ($this->_conn->unitOfWork->contains($record)) {
             return false;
@@ -212,7 +214,7 @@ class Doctrine_Mapper
      * @return boolean  TRUE if the entity was previously not managed and is now managed,
      *                  FALSE otherwise (the entity is already managed).
      */
-    public function manage(Doctrine_Record $record)
+    public function manage(Doctrine_Entity $record)
     {
         return $this->_conn->unitOfWork->manage($record);
     }
@@ -222,11 +224,11 @@ class Doctrine_Mapper
      * removes a record from the identity map, returning true if the record
      * was found and removed and false if the record wasn't found.
      *
-     * @param Doctrine_Record $record       record to be removed
+     * @param Doctrine_Entity $record       record to be removed
      * @return boolean
      * @todo Move elsewhere to the new location of the identity maps.
      */
-    public function removeRecord(Doctrine_Record $record)
+    public function removeRecord(Doctrine_Entity $record)
     {
         if ($this->_conn->unitOfWork->contains($record)) {
             $this->_conn->unitOfWork->unregisterIdentity($record);
@@ -241,7 +243,7 @@ class Doctrine_Mapper
      * First checks if record exists in identityMap, if not
      * returns a new record.
      *
-     * @return Doctrine_Record
+     * @return Doctrine_Entity
      */
     public function getRecord(array $data)
     {
@@ -401,7 +403,7 @@ class Doctrine_Mapper
      * Hydrates the given data into the entity.
      * 
      */
-    /*public function hydrate(Doctrine_Record $entity, array $data)
+    /*public function hydrate(Doctrine_Entity $entity, array $data)
     {
         $this->_values = array_merge($this->_values, $this->cleanData($data));
         $this->_data   = array_merge($this->_data, $data);
@@ -456,12 +458,12 @@ class Doctrine_Mapper
     /**
      * Saves an entity and all it's related entities.
      *
-     * @param Doctrine_Record $record    The entity to save.
+     * @param Doctrine_Entity $record    The entity to save.
      * @param Doctrine_Connection $conn  The connection to use. Will default to the mapper's
      *                                   connection.
      * @throws Doctrine_Mapper_Exception If the mapper is unable to save the given entity.
      */
-    public function save(Doctrine_Record $record, Doctrine_Connection $conn = null)
+    public function save(Doctrine_Entity $record, Doctrine_Connection $conn = null)
     {
         if ( ! ($record instanceof $this->_domainClassName)) {
             throw new Doctrine_Mapper_Exception("Mapper of type " . $this->_domainClassName . " 
@@ -473,11 +475,11 @@ class Doctrine_Mapper
         }
 
         $state = $record->state();
-        if ($state === Doctrine_Record::STATE_LOCKED) {
+        if ($state === Doctrine_Entity::STATE_LOCKED) {
             return false;
         }
         
-        $record->state(Doctrine_Record::STATE_LOCKED);
+        $record->state(Doctrine_Entity::STATE_LOCKED);
         
         try {
             $conn->beginInternalTransaction();
@@ -492,7 +494,7 @@ class Doctrine_Mapper
             }
 
             $state = $record->state();
-            $record->state(Doctrine_Record::STATE_LOCKED);
+            $record->state(Doctrine_Entity::STATE_LOCKED);
 
             foreach ($saveLater as $fk) {
                 $alias = $fk->getAlias();
@@ -521,23 +523,23 @@ class Doctrine_Mapper
     /**
      * Inserts or updates an entity, depending on it's state. 
      *
-     * @param Doctrine_Record $record  The entity to insert/update.
+     * @param Doctrine_Entity $record  The entity to insert/update.
      */
-    protected function _insertOrUpdate(Doctrine_Record $record)
+    protected function _insertOrUpdate(Doctrine_Entity $record)
     {
         $record->preSave();
         $this->notifyEntityListeners($record, 'preSave', Doctrine_Event::RECORD_SAVE);
         
         switch ($record->state()) {
-            case Doctrine_Record::STATE_TDIRTY:
+            case Doctrine_Entity::STATE_TDIRTY:
                 $this->_insert($record);
                 break;
-            case Doctrine_Record::STATE_DIRTY:
-            case Doctrine_Record::STATE_PROXY:
+            case Doctrine_Entity::STATE_DIRTY:
+            case Doctrine_Entity::STATE_PROXY:
                 $this->_update($record);
                 break;
-            case Doctrine_Record::STATE_CLEAN:
-            case Doctrine_Record::STATE_TCLEAN:
+            case Doctrine_Entity::STATE_CLEAN:
+            case Doctrine_Entity::STATE_TCLEAN:
                 // do nothing
                 break;
         }
@@ -549,10 +551,10 @@ class Doctrine_Mapper
     /**
      * saves the given record
      *
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      * @return void
      */
-    public function saveSingleRecord(Doctrine_Record $record)
+    public function saveSingleRecord(Doctrine_Entity $record)
     {
         $this->_insertOrUpdate($record);
     }
@@ -562,9 +564,9 @@ class Doctrine_Mapper
      * saves all related records to $record
      *
      * @throws PDOException         if something went wrong at database level
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      */
-    protected function _saveRelated(Doctrine_Record $record)
+    protected function _saveRelated(Doctrine_Entity $record)
     {
         $saveLater = array();
         foreach ($record->getReferences() as $k => $v) {
@@ -580,7 +582,7 @@ class Doctrine_Mapper
                 $obj = $record->get($rel->getAlias());
 
                 // Protection against infinite function recursion before attempting to save
-                if ($obj instanceof Doctrine_Record && $obj->isModified()) {
+                if ($obj instanceof Doctrine_Entity && $obj->isModified()) {
                     $obj->save($this->_conn);
                     
                     /** Can this be removed?
@@ -609,10 +611,10 @@ class Doctrine_Mapper
      * save new associations to 4 and 5
      *
      * @throws Doctrine_Connection_Exception         if something went wrong at database level
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      * @return void
      */
-    public function saveAssociations(Doctrine_Record $record)
+    public function saveAssociations(Doctrine_Entity $record)
     {
         foreach ($record->getReferences() as $relationName => $relatedObject) {
             if ($relatedObject === Doctrine_Null::$INSTANCE) {
@@ -650,11 +652,11 @@ class Doctrine_Mapper
     /**
      * Updates an entity.
      *
-     * @param Doctrine_Record $record   record to be updated
+     * @param Doctrine_Entity $record   record to be updated
      * @return boolean                  whether or not the update was successful
      * @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
      */
-    protected function _update(Doctrine_Record $record)
+    protected function _update(Doctrine_Entity $record)
     {
         $record->preUpdate();
         $this->notifyEntityListeners($record, 'preUpdate', Doctrine_Event::RECORD_UPDATE);
@@ -671,10 +673,10 @@ class Doctrine_Mapper
     /**
      * Inserts an entity.
      *
-     * @param Doctrine_Record $record   record to be inserted
+     * @param Doctrine_Entity $record   record to be inserted
      * @return boolean
      */
-    protected function _insert(Doctrine_Record $record)
+    protected function _insert(Doctrine_Entity $record)
     {
         $record->preInsert();
         $this->notifyEntityListeners($record, 'preInsert', Doctrine_Event::RECORD_INSERT);
@@ -696,7 +698,7 @@ class Doctrine_Mapper
      * @return boolean      true on success, false on failure
      * @throws Doctrine_Mapper_Exception
      */
-    public function delete(Doctrine_Record $record, Doctrine_Connection $conn = null)
+    public function delete(Doctrine_Entity $record, Doctrine_Connection $conn = null)
     {
         if ( ! $record->exists()) {
             return false;
@@ -717,7 +719,7 @@ class Doctrine_Mapper
         $table = $this->_classMetadata;
 
         $state = $record->state();
-        $record->state(Doctrine_Record::STATE_LOCKED);
+        $record->state(Doctrine_Entity::STATE_LOCKED);
         
         $this->_mappingStrategy->doDelete($record);
         
diff --git a/lib/Doctrine/Mapper/DefaultStrategy.php b/lib/Doctrine/Mapper/DefaultStrategy.php
index 5a093dfd1..bdd4aa6e8 100644
--- a/lib/Doctrine/Mapper/DefaultStrategy.php
+++ b/lib/Doctrine/Mapper/DefaultStrategy.php
@@ -36,7 +36,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
     /**
      * Deletes an entity.
      */
-    public function doDelete(Doctrine_Record $record)
+    public function doDelete(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         $metadata = $this->_mapper->getClassMetadata();
@@ -44,11 +44,11 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
             $conn->beginInternalTransaction();
             $this->_deleteComposites($record);
 
-            $record->state(Doctrine_Record::STATE_TDIRTY);
+            $record->state(Doctrine_Entity::STATE_TDIRTY);
             
             $identifier = $this->_convertFieldToColumnNames($record->identifier(), $metadata);
             $this->_deleteRow($metadata->getTableName(), $identifier);
-            $record->state(Doctrine_Record::STATE_TCLEAN);
+            $record->state(Doctrine_Entity::STATE_TCLEAN);
 
             $this->_mapper->removeRecord($record);
             $conn->commit();
@@ -61,9 +61,9 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
     /**
      * Inserts a single entity into the database, without any related entities.
      *
-     * @param Doctrine_Record $record   The entity to insert.
+     * @param Doctrine_Entity $record   The entity to insert.
      */
-    public function doInsert(Doctrine_Record $record)
+    public function doInsert(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         
@@ -108,7 +108,7 @@ class Doctrine_Mapper_DefaultStrategy extends Doctrine_Mapper_Strategy
     /**
      * Updates an entity.
      */
-    public function doUpdate(Doctrine_Record $record)
+    public function doUpdate(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         $classMetadata = $this->_mapper->getClassMetadata();
diff --git a/lib/Doctrine/Mapper/JoinedStrategy.php b/lib/Doctrine/Mapper/JoinedStrategy.php
index 205bd7141..c596cec0a 100644
--- a/lib/Doctrine/Mapper/JoinedStrategy.php
+++ b/lib/Doctrine/Mapper/JoinedStrategy.php
@@ -38,10 +38,10 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
     /**
      * Inserts an entity that is part of a Class Table Inheritance hierarchy.
      *
-     * @param Doctrine_Record $record   record to be inserted
+     * @param Doctrine_Entity $record   record to be inserted
      * @return boolean
      */
-    public function doInsert(Doctrine_Record $record)
+    public function doInsert(Doctrine_Entity $record)
     {
         $class = $this->_mapper->getClassMetadata();
         $conn = $this->_mapper->getConnection();
@@ -92,11 +92,11 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
     /**
      * Updates an entity that is part of a Class Table Inheritance hierarchy.
      *
-     * @param Doctrine_Record $record   record to be updated
+     * @param Doctrine_Entity $record   record to be updated
      * @return boolean                  whether or not the update was successful
      * @todo Move to Doctrine_Table (which will become Doctrine_Mapper).
      */
-    public function doUpdate(Doctrine_Record $record)
+    public function doUpdate(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         $classMetadata = $this->_mapper->getClassMetadata();
@@ -107,7 +107,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
         array_unshift($classes, $component);
 
         foreach ($record as $field => $value) {
-            if ($value instanceof Doctrine_Record) {
+            if ($value instanceof Doctrine_Entity) {
                 if ( ! $value->exists()) {
                     $value->save();
                 }
@@ -130,7 +130,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
      * Deletes an entity that is part of a Class Table Inheritance hierarchy.
      *
      */
-    public function doDelete(Doctrine_Record $record)
+    public function doDelete(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         try {
@@ -138,7 +138,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
             $conn->beginInternalTransaction();
             $this->_deleteComposites($record);
 
-            $record->state(Doctrine_Record::STATE_TDIRTY);
+            $record->state(Doctrine_Entity::STATE_TDIRTY);
 
             $identifier = $this->_convertFieldToColumnNames($record->identifier(), $class);
             
@@ -149,7 +149,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
                 $this->_deleteRow($parentClass->getTableName(), $identifier);
             }
             
-            $record->state(Doctrine_Record::STATE_TCLEAN);
+            $record->state(Doctrine_Entity::STATE_TCLEAN);
 
             $this->_mapper->removeRecord($record);
             $conn->commit();
@@ -286,7 +286,7 @@ class Doctrine_Mapper_JoinedStrategy extends Doctrine_Mapper_Strategy
      *
      * @return array
      */
-    protected function _groupFieldsByDefiningClass(Doctrine_Record $record)
+    protected function _groupFieldsByDefiningClass(Doctrine_Entity $record)
     {
         $conn = $this->_mapper->getConnection();
         $classMetadata = $this->_mapper->getClassMetadata();
diff --git a/lib/Doctrine/Mapper/Strategy.php b/lib/Doctrine/Mapper/Strategy.php
index ed896827e..fb444afaa 100644
--- a/lib/Doctrine/Mapper/Strategy.php
+++ b/lib/Doctrine/Mapper/Strategy.php
@@ -67,14 +67,14 @@ abstract class Doctrine_Mapper_Strategy
      * @throws PDOException         if something went wrong at database level
      * @return void
      */
-    protected function _deleteComposites(Doctrine_Record $record)
+    protected function _deleteComposites(Doctrine_Entity $record)
     {
         $classMetadata = $this->_mapper->getClassMetadata();
         foreach ($classMetadata->getRelations() as $fk) {
             if ($fk->isComposite()) {
                 $obj = $record->get($fk->getAlias());
-                if ($obj instanceof Doctrine_Record && 
-                        $obj->state() != Doctrine_Record::STATE_LOCKED)  {
+                if ($obj instanceof Doctrine_Entity && 
+                        $obj->state() != Doctrine_Entity::STATE_LOCKED)  {
                     $obj->delete($this->_mapper->getConnection());
                 }
             }
@@ -116,9 +116,9 @@ abstract class Doctrine_Mapper_Strategy
         return $this->_mapper->getClassMetadata();
     }
     
-    abstract public function doDelete(Doctrine_Record $record);
-    abstract public function doInsert(Doctrine_Record $record);
-    abstract public function doUpdate(Doctrine_Record $record);
+    abstract public function doDelete(Doctrine_Entity $record);
+    abstract public function doInsert(Doctrine_Entity $record);
+    abstract public function doUpdate(Doctrine_Entity $record);
     
     /**
      * Inserts a row into a table.
diff --git a/lib/Doctrine/Node.php b/lib/Doctrine/Node.php
index c7965edba..f1dd261ae 100644
--- a/lib/Doctrine/Node.php
+++ b/lib/Doctrine/Node.php
@@ -33,7 +33,7 @@
 class Doctrine_Node implements IteratorAggregate
 {
     /**
-     * @param object    $record   reference to associated Doctrine_Record instance
+     * @param object    $record   reference to associated Doctrine_Entity instance
      */
     protected $record;
 
@@ -62,10 +62,10 @@ class Doctrine_Node implements IteratorAggregate
     /**
      * contructor, creates node with reference to record and any options
      *
-     * @param object $record                    instance of Doctrine_Record
+     * @param object $record                    instance of Doctrine_Entity
      * @param array $options                    options
      */
-    public function __construct(Doctrine_Record $record, $options)
+    public function __construct(Doctrine_Entity $record, $options)
     {
         $this->record = $record;
         $this->options = $options;
@@ -90,12 +90,12 @@ class Doctrine_Node implements IteratorAggregate
     /**
      * factory method to return node instance based upon chosen implementation
      *
-     * @param object $record                    instance of Doctrine_Record
+     * @param object $record                    instance of Doctrine_Entity
      * @param string $impName                   implementation (NestedSet, AdjacencyList, MaterializedPath)
      * @param array $options                    options
      * @return object $options                  instance of Doctrine_Node
      */
-    public static function factory(Doctrine_Record $record, $implName, $options = array())
+    public static function factory(Doctrine_Entity $record, $implName, $options = array())
     {
         $class = 'Doctrine_Node_' . $implName;
 
@@ -109,9 +109,9 @@ class Doctrine_Node implements IteratorAggregate
     /**
      * setter for record attribute
      *
-     * @param object $record                    instance of Doctrine_Record
+     * @param object $record                    instance of Doctrine_Entity
      */
-    public function setRecord(Doctrine_Record $record)
+    public function setRecord(Doctrine_Entity $record)
     {
         $this->record = $record;
     }
@@ -119,7 +119,7 @@ class Doctrine_Node implements IteratorAggregate
     /**
      * getter for record attribute
      *
-     * @return object                           instance of Doctrine_Record
+     * @return object                           instance of Doctrine_Entity
      */
     public function getRecord()
     {
diff --git a/lib/Doctrine/Node/Interface.php b/lib/Doctrine/Node/Interface.php
index fa7dac8b5..9c95f6a1f 100644
--- a/lib/Doctrine/Node/Interface.php
+++ b/lib/Doctrine/Node/Interface.php
@@ -63,42 +63,42 @@ interface Doctrine_Node_Interface {
     /**
      * gets record of prev sibling or empty record
      *
-     * @return object Doctrine_Record
+     * @return object Doctrine_Entity
      */
     public function getPrevSibling();
 
     /**
      * gets record of next sibling or empty record
      *
-     * @return object Doctrine_Record
+     * @return object Doctrine_Entity
      */
     public function getNextSibling();
 
     /**
      * gets siblings for node
      *
-     * @return array                            array of sibling Doctrine_Record objects
+     * @return array                            array of sibling Doctrine_Entity objects
      */
     public function getSiblings($includeNode = false);
 
     /**
      * gets record of first child or empty record
      *
-     * @return object Doctrine_Record
+     * @return object Doctrine_Entity
      */
     public function getFirstChild();
 
     /**
      * gets record of last child or empty record
      *
-     * @return object Doctrine_Record
+     * @return object Doctrine_Entity
      */
     public function getLastChild();
 
     /**
      * gets children for node (direct descendants only)
      *
-     * @return array                            array of sibling Doctrine_Record objects
+     * @return array                            array of sibling Doctrine_Entity objects
      */
     public function getChildren();
 
@@ -112,7 +112,7 @@ interface Doctrine_Node_Interface {
     /**
      * gets record of parent or empty record
      *
-     * @return object Doctrine_Record
+     * @return object Doctrine_Entity
      */
     public function getParent();
 
@@ -158,65 +158,65 @@ interface Doctrine_Node_Interface {
      *
      * @return bool
      */
-    public function insertAsParentOf(Doctrine_Record $dest);
+    public function insertAsParentOf(Doctrine_Entity $dest);
 
     /**
      * inserts node as previous sibling of dest record
      *
      * @return bool
      */
-    public function insertAsPrevSiblingOf(Doctrine_Record $dest);
+    public function insertAsPrevSiblingOf(Doctrine_Entity $dest);
 
     /**
      * inserts node as next sibling of dest record
      *
      * @return bool
      */
-    public function insertAsNextSiblingOf(Doctrine_Record $dest);
+    public function insertAsNextSiblingOf(Doctrine_Entity $dest);
 
     /**
      * inserts node as first child of dest record
      *
      * @return bool
      */
-    public function insertAsFirstChildOf(Doctrine_Record $dest);
+    public function insertAsFirstChildOf(Doctrine_Entity $dest);
 
     /**
      * inserts node as first child of dest record
      *
      * @return bool
      */
-    public function insertAsLastChildOf(Doctrine_Record $dest);
+    public function insertAsLastChildOf(Doctrine_Entity $dest);
 
     /**
      * moves node as prev sibling of dest record
      *
      */  
-    public function moveAsPrevSiblingOf(Doctrine_Record $dest);
+    public function moveAsPrevSiblingOf(Doctrine_Entity $dest);
 
     /**
      * moves node as next sibling of dest record
      *
      */
-    public function moveAsNextSiblingOf(Doctrine_Record $dest);
+    public function moveAsNextSiblingOf(Doctrine_Entity $dest);
 
     /**
      * moves node as first child of dest record
      *
      */
-    public function moveAsFirstChildOf(Doctrine_Record $dest);
+    public function moveAsFirstChildOf(Doctrine_Entity $dest);
 
     /**
      * moves node as last child of dest record
      *
      */
-    public function moveAsLastChildOf(Doctrine_Record $dest);
+    public function moveAsLastChildOf(Doctrine_Entity $dest);
 
     /**
      * adds node as last child of record
      *
      */
-    public function addChild(Doctrine_Record $record);
+    public function addChild(Doctrine_Entity $record);
 
     /**
      * determines if node is leaf
@@ -237,21 +237,21 @@ interface Doctrine_Node_Interface {
      *
      * @return bool
      */
-    public function isEqualTo(Doctrine_Record $subj);
+    public function isEqualTo(Doctrine_Entity $subj);
 
     /**
      * determines if node is child of subject node
      *
      * @return bool
      */
-    public function isDescendantOf(Doctrine_Record $subj);
+    public function isDescendantOf(Doctrine_Entity $subj);
 
     /**
      * determines if node is child of or sibling to subject node
      *
      * @return bool
      */
-    public function isDescendantOfOrEqualTo(Doctrine_Record $subj);
+    public function isDescendantOfOrEqualTo(Doctrine_Entity $subj);
 
     /**
      * determines if node is valid
diff --git a/lib/Doctrine/Node/NestedSet.php b/lib/Doctrine/Node/NestedSet.php
index 0c5dc534b..760ec918f 100644
--- a/lib/Doctrine/Node/NestedSet.php
+++ b/lib/Doctrine/Node/NestedSet.php
@@ -76,7 +76,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets record of prev sibling or empty record
      *
-     * @return object     Doctrine_Record            
+     * @return object     Doctrine_Entity            
      */
     public function getPrevSibling()
     {
@@ -102,7 +102,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets record of next sibling or empty record
      *
-     * @return object     Doctrine_Record            
+     * @return object     Doctrine_Entity            
      */
     public function getNextSibling()
     {
@@ -128,7 +128,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets siblings for node
      *
-     * @return array     array of sibling Doctrine_Record objects            
+     * @return array     array of sibling Doctrine_Entity objects            
      */
     public function getSiblings($includeNode = false)
     {
@@ -148,7 +148,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets record of first child or empty record
      *
-     * @return object     Doctrine_Record            
+     * @return object     Doctrine_Entity            
      */
     public function getFirstChild()
     {
@@ -174,7 +174,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets record of last child or empty record
      *
-     * @return object     Doctrine_Record            
+     * @return object     Doctrine_Entity            
      */
     public function getLastChild()
     {
@@ -243,7 +243,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     /**
      * gets record of parent or empty record
      *
-     * @return object     Doctrine_Record            
+     * @return object     Doctrine_Entity            
      */
     public function getParent()
     {
@@ -340,7 +340,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * @return bool
      * @todo Wrap in transaction          
      */
-    public function insertAsParentOf(Doctrine_Record $dest)
+    public function insertAsParentOf(Doctrine_Entity $dest)
     {
         // cannot insert a node that has already has a place within the tree
         if ($this->isValidNode()) {
@@ -382,7 +382,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * @return bool
      * @todo Wrap in transaction       
      */
-    public function insertAsPrevSiblingOf(Doctrine_Record $dest)
+    public function insertAsPrevSiblingOf(Doctrine_Entity $dest)
     {
         // cannot insert a node that has already has a place within the tree
         if ($this->isValidNode())
@@ -408,7 +408,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * @return bool
      * @todo Wrap in transaction           
      */    
-    public function insertAsNextSiblingOf(Doctrine_Record $dest)
+    public function insertAsNextSiblingOf(Doctrine_Entity $dest)
     {
         // cannot insert a node that has already has a place within the tree
         if ($this->isValidNode())
@@ -434,7 +434,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * @return bool
      * @todo Wrap in transaction         
      */
-    public function insertAsFirstChildOf(Doctrine_Record $dest)
+    public function insertAsFirstChildOf(Doctrine_Entity $dest)
     {
         // cannot insert a node that has already has a place within the tree
         if ($this->isValidNode())
@@ -460,7 +460,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * @return bool
      * @todo Wrap in transaction            
      */
-    public function insertAsLastChildOf(Doctrine_Record $dest)
+    public function insertAsLastChildOf(Doctrine_Entity $dest)
     {
         // cannot insert a node that has already has a place within the tree
         if ($this->isValidNode())
@@ -484,12 +484,12 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * Accomplishes moving of nodes between different trees.
      * Used by the move* methods if the root values of the two nodes are different.
      *
-     * @param Doctrine_Record $dest
+     * @param Doctrine_Entity $dest
      * @param unknown_type $newLeftValue
      * @param unknown_type $moveType
      * @todo Better exception handling/wrapping
      */
-    private function _moveBetweenTrees(Doctrine_Record $dest, $newLeftValue, $moveType)
+    private function _moveBetweenTrees(Doctrine_Entity $dest, $newLeftValue, $moveType)
     {
         $conn = $this->record->getTable()->getConnection();
             
@@ -571,7 +571,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * moves node as prev sibling of dest record
      * 
      */     
-    public function moveAsPrevSiblingOf(Doctrine_Record $dest)
+    public function moveAsPrevSiblingOf(Doctrine_Entity $dest)
     {
         if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
             // Move between trees
@@ -588,7 +588,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * moves node as next sibling of dest record
      *        
      */
-    public function moveAsNextSiblingOf(Doctrine_Record $dest)
+    public function moveAsNextSiblingOf(Doctrine_Entity $dest)
     {
         if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
             // Move between trees
@@ -605,7 +605,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * moves node as first child of dest record
      *            
      */
-    public function moveAsFirstChildOf(Doctrine_Record $dest)
+    public function moveAsFirstChildOf(Doctrine_Entity $dest)
     {
         if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
             // Move between trees
@@ -622,7 +622,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * moves node as last child of dest record
      *        
      */
-    public function moveAsLastChildOf(Doctrine_Record $dest)
+    public function moveAsLastChildOf(Doctrine_Entity $dest)
     {
         if ($dest->getNode()->getRootValue() != $this->getRootValue()) {
             // Move between trees
@@ -695,7 +695,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      * adds node as last child of record
      *        
      */
-    public function addChild(Doctrine_Record $record)
+    public function addChild(Doctrine_Entity $record)
     {
         $record->getNode()->insertAsLastChildOf($this->getRecord());
     }
@@ -725,7 +725,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      *
      * @return bool            
      */    
-    public function isEqualTo(Doctrine_Record $subj)
+    public function isEqualTo(Doctrine_Entity $subj)
     {
         return (($this->getLeftValue() == $subj->getNode()->getLeftValue()) &&
                 ($this->getRightValue() == $subj->getNode()->getRightValue()) && 
@@ -738,7 +738,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      *
      * @return bool
      */
-    public function isDescendantOf(Doctrine_Record $subj)
+    public function isDescendantOf(Doctrine_Entity $subj)
     {
         return (($this->getLeftValue() > $subj->getNode()->getLeftValue()) &&
                 ($this->getRightValue() < $subj->getNode()->getRightValue()) &&
@@ -750,7 +750,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
      *
      * @return bool            
      */
-    public function isDescendantOfOrEqualTo(Doctrine_Record $subj)
+    public function isDescendantOfOrEqualTo(Doctrine_Entity $subj)
     {
         return (($this->getLeftValue() >= $subj->getNode()->getLeftValue()) &&
                 ($this->getRightValue() <= $subj->getNode()->getRightValue()) &&
@@ -766,7 +766,7 @@ class Doctrine_Node_NestedSet extends Doctrine_Node implements Doctrine_Node_Int
     {
         if ($record === null) {
           return ($this->getRightValue() > $this->getLeftValue());
-        } else if ( $record instanceof Doctrine_Record ) {
+        } else if ( $record instanceof Doctrine_Entity ) {
           return ($record->getNode()->getRightValue() > $record->getNode()->getLeftValue());
         } else {
           return false;
diff --git a/lib/Doctrine/Node/NestedSet/PreOrderIterator.php b/lib/Doctrine/Node/NestedSet/PreOrderIterator.php
index 7fcc1ba2d..a360836bc 100644
--- a/lib/Doctrine/Node/NestedSet/PreOrderIterator.php
+++ b/lib/Doctrine/Node/NestedSet/PreOrderIterator.php
@@ -119,7 +119,7 @@ class Doctrine_Node_NestedSet_PreOrderIterator implements Iterator
     /**
      * returns the current record
      *
-     * @return Doctrine_Record
+     * @return Doctrine_Entity
      */
     public function current()
     {
diff --git a/lib/Doctrine/Query.php b/lib/Doctrine/Query.php
index 7e9bb166c..f0e46e5bc 100644
--- a/lib/Doctrine/Query.php
+++ b/lib/Doctrine/Query.php
@@ -1797,7 +1797,7 @@ class Doctrine_Query extends Doctrine_Query_Abstract implements Countable, Seria
      * unseralize
      * this method is automatically called everytime a Doctrine_Hydrate object is unserialized
      *
-     * @param string $serialized                Doctrine_Record as serialized string
+     * @param string $serialized                Doctrine_Entity as serialized string
      * @return void
      */
     public function unserialize($serialized)
diff --git a/lib/Doctrine/Query/Abstract.php b/lib/Doctrine/Query/Abstract.php
index 8b6a344f2..a49c649a8 100644
--- a/lib/Doctrine/Query/Abstract.php
+++ b/lib/Doctrine/Query/Abstract.php
@@ -249,7 +249,7 @@ abstract class Doctrine_Query_Abstract
             $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
         }
         if ($hydrator === null) {
-            $hydrator = new Doctrine_Hydrator();
+            $hydrator = new Doctrine_Hydrator($connection);
         }
         $this->_conn = $connection;
         $this->_hydrator = $hydrator;
@@ -988,9 +988,9 @@ abstract class Doctrine_Query_Abstract
             if ($cached === false) {
                 // cache miss
                 $stmt = $this->_execute($params);
-                $this->_hydrator->setQueryComponents($this->_queryComponents);
-                $result = $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap,
-                        Doctrine::HYDRATE_ARRAY);
+                $result = $this->_hydrator->hydrateResultSet(
+                        $this->_createParserResult($stmt, $this->_queryComponents,
+                                $this->_tableAliasMap, Doctrine::HYDRATE_ARRAY));
 
                 $cached = $this->getCachedForm($result);
                 $cacheDriver->save($hash, $cached, $this->_resultCacheTTL);
@@ -1005,11 +1005,32 @@ abstract class Doctrine_Query_Abstract
                 return $stmt;
             }
             
-            $this->_hydrator->setQueryComponents($this->_queryComponents);
-            return $this->_hydrator->hydrateResultSet($stmt, $this->_tableAliasMap, $hydrationMode);
+            return $this->_hydrator->hydrateResultSet(
+                    $this->_createParserResult($stmt, $this->_queryComponents,
+                            $this->_tableAliasMap, $hydrationMode));
         }
     }
     
+    /**
+     * Creates a parser result object.
+     *
+     * @param unknown_type $stmt
+     * @param unknown_type $queryComponents
+     * @param unknown_type $tableToClassAliasMap
+     * @param unknown_type $hydrationMode
+     * @return unknown
+     */
+    private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
+            $hydrationMode)
+    {
+        $parserResult = new Doctrine_Query_ParserResultDummy();
+        $parserResult->setDatabaseStatement($stmt);
+        $parserResult->setHydrationMode($hydrationMode);
+        $parserResult->setQueryComponents($queryComponents);
+        $parserResult->setTableToClassAliasMap($tableToClassAliasMap);
+        return $parserResult;
+    }
+    
     /**
      * Constructs the query from the cached form.
      * 
diff --git a/lib/Doctrine/Query/ParserResultDummy.php b/lib/Doctrine/Query/ParserResultDummy.php
new file mode 100644
index 000000000..5bfd10736
--- /dev/null
+++ b/lib/Doctrine/Query/ParserResultDummy.php
@@ -0,0 +1,75 @@
+_isMixedQuery;
+    }
+    
+    public function isIdentityQuery()
+    {
+        return $this->_isIdentityQuery;
+    }
+    
+    public function setMixedQuery($bool)
+    {
+        $this->_isMixedQuery = (bool) $bool;
+    }
+    
+    public function getDatabaseStatement()
+    {
+        return $this->_dbStatement;
+    }
+    
+    public function setDatabaseStatement($stmt)
+    {
+        $this->_dbStatement = $stmt;
+    }
+    
+    public function getHydrationMode()
+    {
+        return $this->_hydrationMode;
+    }
+    
+    public function setHydrationMode($hydrationMode)
+    {
+        $this->_hydrationMode = $hydrationMode;
+    }
+    
+    public function getTableToClassAliasMap()
+    {
+        return $this->_tableToClassAliasMap;
+    }
+    
+    public function setTableToClassAliasMap(array $map)
+    {
+        $this->_tableToClassAliasMap = $map;
+    }
+    
+    public function setQueryComponents(array $queryComponents)
+    {
+        $this->_queryComponents = $queryComponents;
+    }
+    
+    public function getQueryComponents()
+    {
+        return $this->_queryComponents;
+    }
+}
+
+
+?>
\ No newline at end of file
diff --git a/lib/Doctrine/Record/Filter.php b/lib/Doctrine/Record/Filter.php
index 0d0a20218..b0d6bb2e4 100644
--- a/lib/Doctrine/Record/Filter.php
+++ b/lib/Doctrine/Record/Filter.php
@@ -20,7 +20,7 @@
  */
 
 /**
- * Doctrine_Record_Filter
+ * Doctrine_Entity_Filter
  * Filters the record getters and setters
  *
  * @package     Doctrine
@@ -46,17 +46,17 @@ abstract class Doctrine_Record_Filter
 
     /**
      * filterSet
-     * defines an implementation for filtering the set() method of Doctrine_Record
+     * defines an implementation for filtering the set() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    abstract public function filterSet(Doctrine_Record $record, $name, $value);
+    abstract public function filterSet(Doctrine_Entity $record, $name, $value);
 
     /**
      * filterGet
-     * defines an implementation for filtering the get() method of Doctrine_Record
+     * defines an implementation for filtering the get() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    abstract public function filterGet(Doctrine_Record $record, $name);
+    abstract public function filterGet(Doctrine_Entity $record, $name);
 }
\ No newline at end of file
diff --git a/lib/Doctrine/Record/Filter/Compound.php b/lib/Doctrine/Record/Filter/Compound.php
index e863f6fc3..db435a02a 100644
--- a/lib/Doctrine/Record/Filter/Compound.php
+++ b/lib/Doctrine/Record/Filter/Compound.php
@@ -48,11 +48,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
 
     /**
      * filterSet
-     * defines an implementation for filtering the set() method of Doctrine_Record
+     * defines an implementation for filtering the set() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    public function filterSet(Doctrine_Record $record, $name, $value)
+    public function filterSet(Doctrine_Entity $record, $name, $value)
     {
         foreach ($this->_aliases as $alias) {
             if ( ! $record->exists()) {
@@ -76,11 +76,11 @@ class Doctrine_Record_Filter_Compound extends Doctrine_Record_Filter
 
     /**
      * filterGet
-     * defines an implementation for filtering the get() method of Doctrine_Record
+     * defines an implementation for filtering the get() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    public function filterGet(Doctrine_Record $record, $name)
+    public function filterGet(Doctrine_Entity $record, $name)
     {
         foreach ($this->_aliases as $alias) {
             if ( ! $record->exists()) {
diff --git a/lib/Doctrine/Record/Filter/Standard.php b/lib/Doctrine/Record/Filter/Standard.php
index dda01f48b..fb23b1200 100644
--- a/lib/Doctrine/Record/Filter/Standard.php
+++ b/lib/Doctrine/Record/Filter/Standard.php
@@ -35,22 +35,22 @@ class Doctrine_Record_Filter_Standard extends Doctrine_Record_Filter
 {
     /**
      * filterSet
-     * defines an implementation for filtering the set() method of Doctrine_Record
+     * defines an implementation for filtering the set() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    public function filterSet(Doctrine_Record $record, $name, $value)
+    public function filterSet(Doctrine_Entity $record, $name, $value)
     {
         throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
     }
 
     /**
      * filterGet
-     * defines an implementation for filtering the get() method of Doctrine_Record
+     * defines an implementation for filtering the get() method of Doctrine_Entity
      *
      * @param mixed $name                       name of the property or related component
      */
-    public function filterGet(Doctrine_Record $record, $name)
+    public function filterGet(Doctrine_Entity $record, $name)
     {
         throw new Doctrine_Record_Exception(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record)));
     }
diff --git a/lib/Doctrine/Record/Iterator.php b/lib/Doctrine/Record/Iterator.php
index 52e0cb7e3..be3d1beaa 100644
--- a/lib/Doctrine/Record/Iterator.php
+++ b/lib/Doctrine/Record/Iterator.php
@@ -33,7 +33,7 @@
 class Doctrine_Record_Iterator extends ArrayIterator
 {
     /**
-     * @var Doctrine_Record $record
+     * @var Doctrine_Entity $record
      */
     private $record;
 
@@ -45,9 +45,9 @@ class Doctrine_Record_Iterator extends ArrayIterator
     /**
      * constructor
      *
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      */
-    public function __construct(Doctrine_Record $record)
+    public function __construct(Doctrine_Entity $record)
     {
         $this->record = $record;
         parent::__construct($record->getData());
diff --git a/lib/Doctrine/Relation.php b/lib/Doctrine/Relation.php
index 140a0c3df..03838cae8 100644
--- a/lib/Doctrine/Relation.php
+++ b/lib/Doctrine/Relation.php
@@ -354,10 +354,10 @@ abstract class Doctrine_Relation implements ArrayAccess
      *
      * fetches a component related to given record
      *
-     * @param Doctrine_Record $record
-     * @return Doctrine_Record|Doctrine_Collection
+     * @param Doctrine_Entity $record
+     * @return Doctrine_Entity|Doctrine_Collection
      */
-    abstract public function fetchRelatedFor(Doctrine_Record $record);
+    abstract public function fetchRelatedFor(Doctrine_Entity $record);
 
     /**
      * __toString
diff --git a/lib/Doctrine/Relation/Association.php b/lib/Doctrine/Relation/Association.php
index dfb744891..c43c3f598 100644
--- a/lib/Doctrine/Relation/Association.php
+++ b/lib/Doctrine/Relation/Association.php
@@ -89,10 +89,10 @@ class Doctrine_Relation_Association extends Doctrine_Relation
      *
      * fetches a component related to given record
      *
-     * @param Doctrine_Record $record
-     * @return Doctrine_Record|Doctrine_Collection
+     * @param Doctrine_Entity $record
+     * @return Doctrine_Entity|Doctrine_Collection
      */
-    public function fetchRelatedFor(Doctrine_Record $record)
+    public function fetchRelatedFor(Doctrine_Entity $record)
     {
         // FIXME: composite key support
         $ids = $record->identifier();
diff --git a/lib/Doctrine/Relation/Association/Self.php b/lib/Doctrine/Relation/Association/Self.php
index ec11adb38..12209c9ef 100644
--- a/lib/Doctrine/Relation/Association/Self.php
+++ b/lib/Doctrine/Relation/Association/Self.php
@@ -74,7 +74,7 @@ class Doctrine_Relation_Association_Self extends Doctrine_Relation_Association
         return $dql;
     }
 
-    public function fetchRelatedFor(Doctrine_Record $record)
+    public function fetchRelatedFor(Doctrine_Entity $record)
     {
         // FIXME: composite key support
         $ids = $record->identifier();
diff --git a/lib/Doctrine/Relation/ForeignKey.php b/lib/Doctrine/Relation/ForeignKey.php
index 70fadd952..1ffc0f55c 100644
--- a/lib/Doctrine/Relation/ForeignKey.php
+++ b/lib/Doctrine/Relation/ForeignKey.php
@@ -38,10 +38,10 @@ class Doctrine_Relation_ForeignKey extends Doctrine_Relation
      *
      * fetches a component related to given record
      *
-     * @param Doctrine_Record $record
-     * @return Doctrine_Record|Doctrine_Collection
+     * @param Doctrine_Entity $record
+     * @return Doctrine_Entity|Doctrine_Collection
      */
-    public function fetchRelatedFor(Doctrine_Record $record)
+    public function fetchRelatedFor(Doctrine_Entity $record)
     {
         $id = array();
         $localTable = $record->getTable();
diff --git a/lib/Doctrine/Relation/LocalKey.php b/lib/Doctrine/Relation/LocalKey.php
index 2628e115c..623ba9276 100644
--- a/lib/Doctrine/Relation/LocalKey.php
+++ b/lib/Doctrine/Relation/LocalKey.php
@@ -38,10 +38,10 @@ class Doctrine_Relation_LocalKey extends Doctrine_Relation
      *
      * fetches a component related to given record
      *
-     * @param Doctrine_Record $record
-     * @return Doctrine_Record|Doctrine_Collection
+     * @param Doctrine_Entity $record
+     * @return Doctrine_Entity|Doctrine_Collection
      */
-    public function fetchRelatedFor(Doctrine_Record $record)
+    public function fetchRelatedFor(Doctrine_Entity $record)
     {
         $localFieldName = $record->getTable()->getFieldName($this->definition['local']);
         $id = $record->get($localFieldName);
diff --git a/lib/Doctrine/Relation/Nest.php b/lib/Doctrine/Relation/Nest.php
index 1c7c623fd..ff22c20c6 100644
--- a/lib/Doctrine/Relation/Nest.php
+++ b/lib/Doctrine/Relation/Nest.php
@@ -74,7 +74,7 @@ class Doctrine_Relation_Nest extends Doctrine_Relation_Association
         return $dql;
     }
 
-    public function fetchRelatedFor(Doctrine_Record $record)
+    public function fetchRelatedFor(Doctrine_Entity $record)
     {
         // FIXME: composite key support
         $ids = $record->identifier();
diff --git a/lib/Doctrine/Search.php b/lib/Doctrine/Search.php
index 929364c23..fe524c7d1 100644
--- a/lib/Doctrine/Search.php
+++ b/lib/Doctrine/Search.php
@@ -96,7 +96,7 @@ class Doctrine_Search extends Doctrine_Record_Generator
      * updateIndex
      * updates the index
      *
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      * @return integer
      */
     public function updateIndex(array $data)
diff --git a/lib/Doctrine/Template.php b/lib/Doctrine/Template.php
index 15d489b1d..7d1ae9bb7 100644
--- a/lib/Doctrine/Template.php
+++ b/lib/Doctrine/Template.php
@@ -33,7 +33,7 @@
 class Doctrine_Template
 {
     /**
-     * @param Doctrine_Record $_invoker     the record that invoked the last delegated call
+     * @param Doctrine_Entity $_invoker     the record that invoked the last delegated call
      */
     protected $_invoker;
     
@@ -66,10 +66,10 @@ class Doctrine_Template
      *
      * sets the last used invoker
      *
-     * @param Doctrine_Record $invoker      the record that invoked the last delegated call
+     * @param Doctrine_Entity $invoker      the record that invoked the last delegated call
      * @return Doctrine_Template            this object
      */
-    public function setInvoker(Doctrine_Record $invoker)
+    public function setInvoker(Doctrine_Entity $invoker)
     {
         $this->_invoker = $invoker;
     }
@@ -78,7 +78,7 @@ class Doctrine_Template
      * setInvoker
      * returns the last used invoker
      *
-     * @return Doctrine_Record              the record that invoked the last delegated call
+     * @return Doctrine_Entity              the record that invoked the last delegated call
      */
     public function getInvoker()
     {
diff --git a/lib/Doctrine/Template/Geographical.php b/lib/Doctrine/Template/Geographical.php
index 5050503ac..4fc1cb46f 100644
--- a/lib/Doctrine/Template/Geographical.php
+++ b/lib/Doctrine/Template/Geographical.php
@@ -92,7 +92,7 @@ class Doctrine_Template_Geographical extends Doctrine_Template
         return $query;
     }
 
-    public function getDistance(Doctrine_Record $record, $kilometers = false)
+    public function getDistance(Doctrine_Entity $record, $kilometers = false)
     {
         $query = $this->getDistanceQuery($kilometers);
         
diff --git a/lib/Doctrine/Transaction.php b/lib/Doctrine/Transaction.php
index 712ece4c3..d9a77e4c7 100644
--- a/lib/Doctrine/Transaction.php
+++ b/lib/Doctrine/Transaction.php
@@ -129,12 +129,12 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
      * addInvalid
      * adds record into invalid records list
      *
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      * @return boolean        false if record already existed in invalid records list,
      *                        otherwise true
      * @todo package:orm
      */
-    public function addInvalid(Doctrine_Record $record)
+    public function addInvalid(Doctrine_Entity $record)
     {
         if (in_array($record, $this->invalid, true)) {
             return false;
diff --git a/lib/Doctrine/Tree/Interface.php b/lib/Doctrine/Tree/Interface.php
index a280bc819..159379d78 100644
--- a/lib/Doctrine/Tree/Interface.php
+++ b/lib/Doctrine/Tree/Interface.php
@@ -35,14 +35,14 @@ interface Doctrine_Tree_Interface {
     /**
      * creates root node from given record or from a new record
      *
-     * @param object $record                    instance of Doctrine_Record
+     * @param object $record                    instance of Doctrine_Entity
      */
-    public function createRoot(Doctrine_Record $record = null);
+    public function createRoot(Doctrine_Entity $record = null);
 
     /**
      * returns root node
      *
-     * @return object $record                   instance of Doctrine_Record
+     * @return object $record                   instance of Doctrine_Entity
      */
     public function findRoot($root_id = 1);
 
diff --git a/lib/Doctrine/Tree/NestedSet.php b/lib/Doctrine/Tree/NestedSet.php
index 9dffd77c4..316e09774 100644
--- a/lib/Doctrine/Tree/NestedSet.php
+++ b/lib/Doctrine/Tree/NestedSet.php
@@ -71,9 +71,9 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
     /**
      * creates root node from given record or from a new record
      *
-     * @param object $record        instance of Doctrine_Record
+     * @param object $record        instance of Doctrine_Entity
      */
-    public function createRoot(Doctrine_Record $record = null)
+    public function createRoot(Doctrine_Entity $record = null)
     {
         if ( ! $record) {
             $record = $this->table->create();
@@ -96,7 +96,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
     /**
      * returns root node
      *
-     * @return object $record        instance of Doctrine_Record
+     * @return object $record        instance of Doctrine_Entity
      * @deprecated Use fetchRoot()
      */
     public function findRoot($rootId = 1)
@@ -178,7 +178,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
     public function fetchBranch($pk, $options = array())
     {
         $record = $this->table->find($pk);
-        if ( ! ($record instanceof Doctrine_Record) || !$record->exists()) {
+        if ( ! ($record instanceof Doctrine_Entity) || !$record->exists()) {
             // TODO: if record doesn't exist, throw exception or similar?
             return false;
         }
diff --git a/lib/Doctrine/Validator.php b/lib/Doctrine/Validator.php
index 6898a1adf..4a342d143 100644
--- a/lib/Doctrine/Validator.php
+++ b/lib/Doctrine/Validator.php
@@ -65,10 +65,10 @@ class Doctrine_Validator
      * validates a given record and saves possible errors
      * in Doctrine_Validator::$stack
      *
-     * @param Doctrine_Record $record
+     * @param Doctrine_Entity $record
      * @return void
      */
-    public function validateRecord(Doctrine_Record $record)
+    public function validateRecord(Doctrine_Entity $record)
     {
         $classMetadata = $record->getTable();
         $columns   = $record->getTable()->getColumns();
@@ -83,7 +83,7 @@ class Doctrine_Validator
         foreach ($fields as $fieldName => $value) {
             if ($value === Doctrine_Null::$INSTANCE) {
                 $value = null;
-            } else if ($value instanceof Doctrine_Record) {
+            } else if ($value instanceof Doctrine_Entity) {
                 $ids = $value->identifier();
                 $value = count($ids) > 0 ? array_pop($ids) : null;
             }
diff --git a/lib/Doctrine/Validator/Unique.php b/lib/Doctrine/Validator/Unique.php
index cad77fa91..1863f116d 100644
--- a/lib/Doctrine/Validator/Unique.php
+++ b/lib/Doctrine/Validator/Unique.php
@@ -56,7 +56,7 @@ class Doctrine_Validator_Unique
         // unique value already exists in the database IF the record in the database is the same
         // as the one that is validated here.
         $state = $this->invoker->state();
-        if ( ! ($state == Doctrine_Record::STATE_TDIRTY || $state == Doctrine_Record::STATE_TCLEAN)) {
+        if ( ! ($state == Doctrine_Entity::STATE_TDIRTY || $state == Doctrine_Entity::STATE_TCLEAN)) {
             foreach ((array) $table->getIdentifier() as $pk) {
                 $sql .= " AND {$pk} != ?";
                 $values[] = $this->invoker->$pk;
diff --git a/lib/Doctrine/View.php b/lib/Doctrine/View.php
index c750288f7..66824e3e0 100644
--- a/lib/Doctrine/View.php
+++ b/lib/Doctrine/View.php
@@ -146,7 +146,7 @@ class Doctrine_View
     /**
      * execute
      * executes the view
-     * returns a collection of Doctrine_Record objects
+     * returns a collection of Doctrine_Entity objects
      *
      * @return Doctrine_Collection
      */
diff --git a/tests/Orm/Hydration/BasicHydrationTest.php b/tests/Orm/Hydration/BasicHydrationTest.php
index 208c15607..bedba6e6f 100644
--- a/tests/Orm/Hydration/BasicHydrationTest.php
+++ b/tests/Orm/Hydration/BasicHydrationTest.php
@@ -4,9 +4,12 @@ require_once 'lib/mocks/Doctrine_HydratorMockStatement.php';
  
 class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
 {
+    private $_em;
+    
     protected function setUp()
     {
         parent::setUp();
+        $this->_em = $this->sharedFixture['connection'];
     }
     
     /** Getter for the hydration mode dataProvider */
@@ -18,13 +21,26 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         );
     }
     
+    /** Helper method */
+    private function _createParserResult($stmt, $queryComponents, $tableToClassAliasMap,
+            $hydrationMode, $isMixedQuery = false)
+    {
+        $parserResult = new Doctrine_Query_ParserResultDummy();
+        $parserResult->setDatabaseStatement($stmt);
+        $parserResult->setHydrationMode($hydrationMode);
+        $parserResult->setQueryComponents($queryComponents);
+        $parserResult->setTableToClassAliasMap($tableToClassAliasMap);
+        $parserResult->setMixedQuery($isMixedQuery);
+        return $parserResult;
+    }
+    
     /**
      * Select u.id, u.name from CmsUser u
      *
      * @dataProvider hydrationModeProvider
      */
     public function testNewHydrationSimpleEntityQuery($hydrationMode)
-    {
+    {        
         // Faked query components
         $queryComponents = array(
             'u' => array(
@@ -55,10 +71,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);        
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode));        
         
         $this->assertEquals(2, count($result));
         $this->assertEquals(1, $result[0]['id']);
@@ -68,8 +84,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
           
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
             $this->assertTrue($result instanceof Doctrine_Collection);
-            $this->assertTrue($result[0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1] instanceof Doctrine_Record);
+            $this->assertTrue($result[0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1] instanceof Doctrine_Entity);
         } else {
             $this->assertTrue(is_array($result));
         }
@@ -135,12 +151,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
             );
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        $hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
         //var_dump($result);
         
         $this->assertEquals(2, count($result));
@@ -161,11 +175,11 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         $this->assertEquals(91, $result[1][0]['phonenumbers'][0]['phonenumber']);
         
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
-            $this->assertTrue($result[0][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
             $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
             $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
         } 
     }
@@ -223,12 +237,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        $hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
         //var_dump($result);
         
         $this->assertEquals(2, count($result));
@@ -242,8 +254,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         $this->assertEquals(1, $result[1]['numPhones']);
         
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
-            $this->assertTrue($result[0][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
         }
     }
     
@@ -308,13 +320,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        // give the hydrator an artificial hint
-        $hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
         if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
             //var_dump($result);
         }
@@ -340,8 +349,8 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         $this->assertEquals('JWAGE', $result[1]['nameUpper']);
         
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
-            $this->assertTrue($result[0]['1'] instanceof Doctrine_Record);
-            $this->assertTrue($result[1]['2'] instanceof Doctrine_Record);
+            $this->assertTrue($result[0]['1'] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1]['2'] instanceof Doctrine_Entity);
             $this->assertTrue($result[0]['1']['phonenumbers'] instanceof Doctrine_Collection);
             $this->assertEquals(2, count($result[0]['1']['phonenumbers']));
         }
@@ -450,12 +459,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
             );
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        $hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
         if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
             //var_dump($result);
         }
@@ -484,18 +491,18 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         $this->assertEquals('PHP6', $result[1][0]['articles'][1]['topic']);
         
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
-            $this->assertTrue($result[0][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
             $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
             $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
             $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record);
+            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
         }
     }
     
@@ -625,12 +632,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
             );
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        $hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode, true));
         if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
             //var_dump($result);
         }
@@ -667,23 +672,23 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
         $this->assertFalse(isset($result[1][0]['articles'][1]['comments']));
         
         if ($hydrationMode == Doctrine::HYDRATE_RECORD) {
-            $this->assertTrue($result[0][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0] instanceof Doctrine_Entity);
             // phonenumbers
             $this->assertTrue($result[0][0]['phonenumbers'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['phonenumbers'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[0][0]['phonenumbers'][1] instanceof Doctrine_Entity);
             $this->assertTrue($result[1][0]['phonenumbers'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[1][0]['phonenumbers'][0] instanceof Doctrine_Entity);
             // articles
             $this->assertTrue($result[0][0]['articles'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['articles'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[0][0]['articles'][1] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0]['articles'][0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1][0]['articles'][1] instanceof Doctrine_Entity);
             // article comments
             $this->assertTrue($result[0][0]['articles'][0]['comments'] instanceof Doctrine_Collection);
-            $this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Record);
+            $this->assertTrue($result[0][0]['articles'][0]['comments'][0] instanceof Doctrine_Entity);
         }
     }
     
@@ -772,12 +777,10 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
             );
             
         $stmt = new Doctrine_HydratorMockStatement($resultSet);
-        $hydrator = new Doctrine_HydratorNew();
-        $hydrator->setQueryComponents($queryComponents);
+        $hydrator = new Doctrine_HydratorNew($this->_em);
         
-        //$hydrator->setResultMixed(true);
-        
-        $result = $hydrator->hydrateResultSet($stmt, $tableAliasMap, $hydrationMode);
+        $result = $hydrator->hydrateResultSet($this->_createParserResult(
+                $stmt, $queryComponents, $tableAliasMap, $hydrationMode));
         if ($hydrationMode == Doctrine::HYDRATE_ARRAY) {
             //var_dump($result);
         }
@@ -794,9 +797,9 @@ class Orm_Hydration_BasicHydrationTest extends Doctrine_OrmTestCase
             $this->assertTrue(is_array($result[1]));
         } else {
             $this->assertTrue($result instanceof Doctrine_Collection);
-            $this->assertTrue($result[0] instanceof Doctrine_Record);
-            $this->assertTrue($result[1] instanceof Doctrine_Record);
+            $this->assertTrue($result[0] instanceof Doctrine_Entity);
+            $this->assertTrue($result[1] instanceof Doctrine_Entity);
         }     
 
     }
-}
\ No newline at end of file
+}
diff --git a/tests/Orm/UnitOfWorkTestCase.php b/tests/Orm/UnitOfWorkTestCase.php
index 819f43cf2..178496560 100644
--- a/tests/Orm/UnitOfWorkTestCase.php
+++ b/tests/Orm/UnitOfWorkTestCase.php
@@ -31,7 +31,7 @@ class Orm_UnitOfWorkTestCase extends Doctrine_OrmTestCase
     {
         $this->_user->username = 'romanb';
         $this->_user->id = 1;
-        $this->assertEquals(Doctrine_Record::STATE_TDIRTY, $this->_user->state());
+        $this->assertEquals(Doctrine_Entity::STATE_TDIRTY, $this->_user->state());
         $this->assertFalse($this->_unitOfWork->contains($this->_user));
         $this->_unitOfWork->registerDirty($this->_user);
         $this->assertTrue($this->_unitOfWork->isRegisteredDirty($this->_user));
diff --git a/tests/models/cms/CmsArticle.php b/tests/models/cms/CmsArticle.php
index eec67826b..e9dd55541 100644
--- a/tests/models/cms/CmsArticle.php
+++ b/tests/models/cms/CmsArticle.php
@@ -1,5 +1,5 @@
 mapColumn('position', 'integer');
         $class->mapColumn('category_id', 'integer');
diff --git a/tests/models/forum/ForumCategory.php b/tests/models/forum/ForumCategory.php
index 890f6160c..a5f166d31 100644
--- a/tests/models/forum/ForumCategory.php
+++ b/tests/models/forum/ForumCategory.php
@@ -1,5 +1,5 @@
 mapColumn('position', 'integer');
         $class->mapColumn('name', 'string', 255);
diff --git a/tests/models/forum/ForumUser.php b/tests/models/forum/ForumUser.php
index 6f060104f..f684fe0fe 100644
--- a/tests/models/forum/ForumUser.php
+++ b/tests/models/forum/ForumUser.php
@@ -1,6 +1,6 @@
 assertTrue($this->cache->exists(4));
 
         $record = $this->cache->fetch(4);
-        $this->assertTrue($record instanceof Doctrine_Record);
+        $this->assertTrue($record instanceof Doctrine_Entity);
         $this->assertTrue($record->obtainIdentifier() == $this->old->obtainIdentifier());
         
         $this->assertTrue($this->cache->getTable() == $this->objTable);
diff --git a/tests_old/CacheSqliteTestCase.php b/tests_old/CacheSqliteTestCase.php
index be2aece99..c9749e366 100644
--- a/tests_old/CacheSqliteTestCase.php
+++ b/tests_old/CacheSqliteTestCase.php
@@ -21,7 +21,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
         $this->assertTrue($this->cache->store($this->objTable->find(4)));
 
         $record = $this->cache->fetch(4);
-        $this->assertTrue($record instanceof Doctrine_Record);
+        $this->assertTrue($record instanceof Doctrine_Entity);
 
         foreach($this->old as $name => $value) {
             $this->assertEqual($record->get($name), $value);
@@ -36,7 +36,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
         $array = $this->cache->fetchMultiple(array(5,6));
         $this->assertEqual(gettype($array), "array");
         $this->assertEqual(count($array), 1);
-        $this->assertTrue($array[0] instanceof Doctrine_Record);
+        $this->assertTrue($array[0] instanceof Doctrine_Entity);
     }
     public function testDeleteMultiple() {
         $this->assertEqual($this->cache->deleteMultiple(array()),0);
@@ -52,7 +52,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
     }
     public function testDelete() {
         $this->cache->store($this->objTable->find(5));
-        $this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Record);
+        $this->assertTrue($this->cache->fetch(5) instanceof Doctrine_Entity);
 
         $this->assertEqual($this->cache->delete(5),true);
         $this->assertFalse($this->cache->fetch(5));
diff --git a/tests_old/ClassTableInheritanceTestCase.php b/tests_old/ClassTableInheritanceTestCase.php
index 85f839638..5103fdd4a 100644
--- a/tests_old/ClassTableInheritanceTestCase.php
+++ b/tests_old/ClassTableInheritanceTestCase.php
@@ -225,7 +225,7 @@ class Doctrine_ClassTableInheritance_TestCase extends Doctrine_UnitTestCase
         $this->conn->addListener(new Doctrine_EventListener());
     }
 }
-class CTITestParent1 extends Doctrine_Record
+class CTITestParent1 extends Doctrine_Entity
 {
     public function setTableDefinition()
     {
@@ -265,7 +265,7 @@ class CTITest extends CTITestParent4
     }
 }
 
-class CTITestOneToManyRelated extends Doctrine_Record
+class CTITestOneToManyRelated extends Doctrine_Entity
 {
     public function setTableDefinition()
     {
diff --git a/tests_old/CollectionOffsetTestCase.php b/tests_old/CollectionOffsetTestCase.php
index 671fec15c..2a6afaac1 100644
--- a/tests_old/CollectionOffsetTestCase.php
+++ b/tests_old/CollectionOffsetTestCase.php
@@ -8,16 +8,16 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
         $this->assertEqual(count($users), 5);
         $users[5];
 
-        $this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
         $users[5];
 
         $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
 
         $users = $this->connection->query("FROM User-o");
         $this->assertEqual(count($users), 3);
-        $this->assertEqual($users[0]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($users[1]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($users[2]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($users[1]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($users[2]->getState(), Doctrine_Entity::STATE_CLEAN);
         // indexes 0,1,2 in use
 
         $users[7];
@@ -28,15 +28,15 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
         $this->assertTrue($users->contains(6));
         $this->assertTrue($users->contains(7));
 
-        $this->assertEqual($users[6]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($users[7]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[6]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($users[7]->getState(), Doctrine_Entity::STATE_CLEAN);
 
 
         $users[5];
         $this->assertEqual(count($users), 8);
-        $this->assertEqual($users[3]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($users[4]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($users[5]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[3]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($users[4]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($users[5]->getState(), Doctrine_Entity::STATE_CLEAN);
 
 
         $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 1);
@@ -61,8 +61,8 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
         foreach($coll as $user) {
         }
         $this->assertEqual($coll->count(), 8);
-        $this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
 
         $this->connection->setAttribute(Doctrine::ATTR_COLL_LIMIT, 3);
 
@@ -71,7 +71,7 @@ class Doctrine_Collection_Offset_TestCase extends Doctrine_UnitTestCase {
         foreach($coll as $user) {
         }
         $this->assertEqual($coll->count(), 8);
-        $this->assertEqual($coll[3]->getState(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($coll[6]->getState(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($coll[3]->getState(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($coll[6]->getState(), Doctrine_Entity::STATE_CLEAN);
     }
 }
diff --git a/tests_old/CollectionTestCase.php b/tests_old/CollectionTestCase.php
index 75d54e94f..c592d646d 100644
--- a/tests_old/CollectionTestCase.php
+++ b/tests_old/CollectionTestCase.php
@@ -251,7 +251,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual(count($coll), 3);
 
-        $this->assertEqual($coll[2]->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($coll[2]->state(), Doctrine_Entity::STATE_PROXY);
 
 
 
@@ -287,8 +287,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
         $this->assertFalse($users->contains(0));
         $this->assertEqual($users->count(), 8);
         
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); 
-        $this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN); 
+        $this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
     }
     public function testFetchCollectionWithNameAsIndex() 
     {
@@ -299,8 +299,8 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
         $this->assertFalse($users->contains(0));
         $this->assertEqual($users->count(), 8);
         
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN); 
-        $this->assertEqual($users['zYne']->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN); 
+        $this->assertEqual($users['zYne']->state(), Doctrine_Entity::STATE_CLEAN);
     }
     public function testFetchMultipleCollections() 
     {
@@ -317,16 +317,16 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
         $this->assertFalse($users->contains(0));
         $this->assertEqual($users->count(), 8);
 
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
-        $this->assertEqual($users[2]->state(), Doctrine_Record::STATE_TCLEAN);
-        $this->assertEqual($users[3]->state(), Doctrine_Record::STATE_TCLEAN);
-        $this->assertEqual($users[4]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
+        $this->assertEqual($users[2]->state(), Doctrine_Entity::STATE_TCLEAN);
+        $this->assertEqual($users[3]->state(), Doctrine_Entity::STATE_TCLEAN);
+        $this->assertEqual($users[4]->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($users[4]->name, 'zYne');
 
         $this->assertEqual($users[4]->Phonenumber[0]->exists(), false);
-        $this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($users[4]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
         $this->assertEqual($users[4]->Phonenumber[1]->exists(), false);
-        $this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[4]->Phonenumber[2]->state(), Doctrine_Entity::STATE_CLEAN);
     }
 
 }
diff --git a/tests_old/ConnectionTestCase.php b/tests_old/ConnectionTestCase.php
index 14478e80f..8656d7aff 100644
--- a/tests_old/ConnectionTestCase.php
+++ b/tests_old/ConnectionTestCase.php
@@ -153,7 +153,7 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase
     {
         //$user = $this->connection->create('User');
         //$this->connection->unitOfWork->delete($user);
-        //$this->assertEqual($user->state(),Doctrine_Record::STATE_TCLEAN);
+        //$this->assertEqual($user->state(),Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testGetTable() 
diff --git a/tests_old/CtiColumnAggregationTestCase.php b/tests_old/CtiColumnAggregationTestCase.php
index bd7244d01..7996b49e8 100644
--- a/tests_old/CtiColumnAggregationTestCase.php
+++ b/tests_old/CtiColumnAggregationTestCase.php
@@ -34,7 +34,7 @@ class Doctrine_CtiColumnAggregation_TestCase extends Doctrine_UnitTestCase
 {
 
 }
-abstract class CTICAAbstractBase extends Doctrine_Record
+abstract class CTICAAbstractBase extends Doctrine_Entity
 { }
 class CTICATestParent1 extends CTICAAbstractBase
 {
@@ -85,7 +85,7 @@ class CTICATest2 extends CTICATestParent2
     }
 }
 
-class CTICATestOneToManyRelated extends Doctrine_Record
+class CTICATestOneToManyRelated extends Doctrine_Entity
 {
     public function setTableDefinition()
     {
diff --git a/tests_old/CustomPrimaryKeyTestCase.php b/tests_old/CustomPrimaryKeyTestCase.php
index 445232090..d944877b4 100644
--- a/tests_old/CustomPrimaryKeyTestCase.php
+++ b/tests_old/CustomPrimaryKeyTestCase.php
@@ -44,7 +44,7 @@ class Doctrine_CustomPrimaryKey_TestCase extends Doctrine_UnitTestCase
     public function testOperations() 
     {
         $c = new CustomPK();
-        $this->assertTrue($c instanceof Doctrine_Record);
+        $this->assertTrue($c instanceof Doctrine_Entity);
 
         $c->name = 'custom pk test';
         $this->assertEqual($c->identifier(), array());
diff --git a/tests_old/DataType/BooleanTestCase.php b/tests_old/DataType/BooleanTestCase.php
index 72e92d56a..89efbfc99 100644
--- a/tests_old/DataType/BooleanTestCase.php
+++ b/tests_old/DataType/BooleanTestCase.php
@@ -42,7 +42,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
         $test->is_working = false;
 
         $this->assertIdentical($test->is_working, false);
-        $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
         $test->save();
 
         $test->refresh();
@@ -98,7 +98,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
         $this->is_working = null;
 
         $this->assertIdentical($this->is_working, null);
-        $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
         $test->save();
 
         $test->refresh();
@@ -108,7 +108,7 @@ class Doctrine_DataType_Boolean_TestCase extends Doctrine_UnitTestCase {
         $this->is_working_notnull = null;
 
         $this->assertIdentical($this->is_working_notnull, null);
-        $this->assertEqual($test->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($test->state(), Doctrine_Entity::STATE_TDIRTY);
         $test->save();
 
         $test->refresh();
diff --git a/tests_old/Hydrate/FetchModeTestCase.php b/tests_old/Hydrate/FetchModeTestCase.php
index b1b958a49..0cfd789e2 100644
--- a/tests_old/Hydrate/FetchModeTestCase.php
+++ b/tests_old/Hydrate/FetchModeTestCase.php
@@ -110,7 +110,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
         $this->assertTrue($users[0] instanceof User);
         $this->assertTrue($users instanceof Doctrine_Collection);  
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($users[0]->id, 4);
 
         $this->assertTrue($users[0]['Email'] instanceof Email);
@@ -128,7 +128,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual(count($users), 8);
         $this->assertTrue($users[0] instanceof User);
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertTrue($users instanceof Doctrine_Collection);
         $this->assertTrue($users[0]->Phonenumber instanceof Doctrine_Collection);
     }
@@ -143,7 +143,7 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual(count($users), 8);
         $this->assertTrue($users[0] instanceof User);
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
 
 
         $this->assertEqual($this->conn->count(), $count + 1);
diff --git a/tests_old/HydrateTestCase.php b/tests_old/HydrateTestCase.php
index c55205c9a..cd786a567 100644
--- a/tests_old/HydrateTestCase.php
+++ b/tests_old/HydrateTestCase.php
@@ -101,7 +101,7 @@ class Doctrine_Hydrate_Mock extends Doctrine_Hydrator_Abstract
         $this->data = $data;
     }
     
-    public function hydrateResultSet($stmt, $tableAliases, $hydrationMode = null)
+    public function hydrateResultSet($parserResult)
     {
         return true;
     }
diff --git a/tests_old/Inheritance/JoinedTestCase.php b/tests_old/Inheritance/JoinedTestCase.php
index 00cfb0d57..4fbfa05c3 100644
--- a/tests_old/Inheritance/JoinedTestCase.php
+++ b/tests_old/Inheritance/JoinedTestCase.php
@@ -183,7 +183,7 @@ class Doctrine_Inheritance_Joined_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class CTI_User extends Doctrine_Record
+class CTI_User extends Doctrine_Entity
 {    
     public static function initMetadata($class)
     {
diff --git a/tests_old/Inheritance/SingleTableTestCase.php b/tests_old/Inheritance/SingleTableTestCase.php
index 9b9dab8bb..3619832b5 100644
--- a/tests_old/Inheritance/SingleTableTestCase.php
+++ b/tests_old/Inheritance/SingleTableTestCase.php
@@ -63,7 +63,7 @@ class Doctrine_Inheritance_SingleTable_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class STI_User extends Doctrine_Record
+class STI_User extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Inheritance/TablePerClassTestCase.php b/tests_old/Inheritance/TablePerClassTestCase.php
index a4868c61c..0d837f3c0 100644
--- a/tests_old/Inheritance/TablePerClassTestCase.php
+++ b/tests_old/Inheritance/TablePerClassTestCase.php
@@ -66,7 +66,7 @@ class Doctrine_Inheritance_TablePerClass_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class CCTI_User extends Doctrine_Record
+class CCTI_User extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Metadata/FactoryTestCase.php b/tests_old/Metadata/FactoryTestCase.php
index bebaf641b..95c09dfbc 100644
--- a/tests_old/Metadata/FactoryTestCase.php
+++ b/tests_old/Metadata/FactoryTestCase.php
@@ -141,7 +141,7 @@ class Doctrine_Metadata_Factory_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class Metadata_User extends Doctrine_Record
+class Metadata_User extends Doctrine_Entity
 {    
     public static function initMetadata(Doctrine_ClassMetadata $class)
     {
@@ -195,7 +195,7 @@ class Metadata_SuperManager extends Metadata_Manager
 
 
 
-class Metadata_STI_User extends Doctrine_Record
+class Metadata_STI_User extends Doctrine_Entity
 {    
     public static function initMetadata($class)
     {
diff --git a/tests_old/PessimisticLockingTestCase.php b/tests_old/PessimisticLockingTestCase.php
index 2d2428a53..1c8c59a7f 100644
--- a/tests_old/PessimisticLockingTestCase.php
+++ b/tests_old/PessimisticLockingTestCase.php
@@ -101,7 +101,7 @@ class Doctrine_PessimisticLocking_TestCase extends Doctrine_UnitTestCase {
      * Tests the retrieving of a lock's owner.
      * This test implicitly tests getLock().
      *
-     * @param Doctrine_Record $lockedRecord
+     * @param Doctrine_Entity $lockedRecord
      */
     public function testGetLockOwner() {
         $entries = $this->connection->query("FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'");
diff --git a/tests_old/PluginTestCase.php b/tests_old/PluginTestCase.php
index ce12f37e1..7a58041c1 100644
--- a/tests_old/PluginTestCase.php
+++ b/tests_old/PluginTestCase.php
@@ -59,7 +59,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
     public function testCreatingNewRecordsInvokesAllPlugins()
     {
         $wiki = new Wiki();
-        $wiki->state(Doctrine_Record::STATE_TDIRTY);
+        $wiki->state(Doctrine_Entity::STATE_TDIRTY);
         $wiki->save();
 
         $fi = $wiki->Translation['FI'];
@@ -86,7 +86,7 @@ class Doctrine_Plugin_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($wiki->Translation['FI']->version, 2);
     }
 }
-class Wiki extends Doctrine_Record
+class Wiki extends Doctrine_Entity
 {
     public function setTableDefinition()
     {
diff --git a/tests_old/Query/AggregateValueTestCase.php b/tests_old/Query/AggregateValueTestCase.php
index 1df8b6b94..d52807800 100644
--- a/tests_old/Query/AggregateValueTestCase.php
+++ b/tests_old/Query/AggregateValueTestCase.php
@@ -92,7 +92,7 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
         
         $this->assertEqual($users->count(), 1);
 
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testAggregateValueIsMappedToRecord()
@@ -105,8 +105,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual($users->count(), 2);
         
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY);
-        $this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
+        $this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
         
         $this->assertEqual($users[0]->count, 2);
         $this->assertEqual($users[1]->count, 2);
@@ -122,8 +122,8 @@ class Doctrine_Query_AggregateValue_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual($users->count(), 2);
         
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_PROXY);
-        $this->assertEqual($users[1]->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_PROXY);
+        $this->assertEqual($users[1]->state(), Doctrine_Entity::STATE_PROXY);
         
         $this->assertEqual($users[0]->count, 2);
         $this->assertEqual($users[1]->count, 2);
diff --git a/tests_old/Query/SelectTestCase.php b/tests_old/Query/SelectTestCase.php
index 9fae6a2f2..98ae042f5 100644
--- a/tests_old/Query/SelectTestCase.php
+++ b/tests_old/Query/SelectTestCase.php
@@ -293,7 +293,7 @@ class Doctrine_Query_Select_TestCase extends Doctrine_UnitTestCase
 
         $users = $q->execute();
 
-        $this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($users[0]->Phonenumber[0]->state(), Doctrine_Entity::STATE_TDIRTY);
 
         $this->assertEqual($users[0]->Phonenumber[0]->count, 1);
         $this->assertEqual($users[1]->Phonenumber[0]->count, 3);
diff --git a/tests_old/RawSqlTestCase.php b/tests_old/RawSqlTestCase.php
index ef617093b..cf1dcef37 100644
--- a/tests_old/RawSqlTestCase.php
+++ b/tests_old/RawSqlTestCase.php
@@ -84,8 +84,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual($coll->count(), 11);
 
-        $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY);
-        $this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY); 
+        $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
+        $this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY); 
     }
     public function testSmartMapping() 
     {
@@ -101,8 +101,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual($coll->count(), 11);
 
-        $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_PROXY);
-        $this->assertEqual($coll[3]->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_PROXY);
+        $this->assertEqual($coll[3]->state(), Doctrine_Entity::STATE_PROXY);
     }
 
     public function testMultipleComponents() 
diff --git a/tests_old/Record/FilterTestCase.php b/tests_old/Record/FilterTestCase.php
index 35d56c53e..bda5cc956 100644
--- a/tests_old/Record/FilterTestCase.php
+++ b/tests_old/Record/FilterTestCase.php
@@ -84,7 +84,7 @@ class Doctrine_Record_Filter_TestCase extends Doctrine_UnitTestCase
         }
     }
 }
-class CompositeRecord extends Doctrine_Record
+class CompositeRecord extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
@@ -94,7 +94,7 @@ class CompositeRecord extends Doctrine_Record
     	$class->unshiftFilter(new Doctrine_Record_Filter_Compound(array('Related')));
     }
 }
-class RelatedCompositeRecord extends Doctrine_Record
+class RelatedCompositeRecord extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Record/HookTestCase.php b/tests_old/Record/HookTestCase.php
index 49565dfa6..c132dec48 100644
--- a/tests_old/Record/HookTestCase.php
+++ b/tests_old/Record/HookTestCase.php
@@ -90,11 +90,11 @@ class Doctrine_Record_Hook_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($r->something, 'something');
 
         $this->assertEqual($r->deleted, null);
-        $this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
 
         try {
             $r->delete();
-            $this->assertEqual($r->state(), Doctrine_Record::STATE_CLEAN);
+            $this->assertEqual($r->state(), Doctrine_Entity::STATE_CLEAN);
             $this->assertEqual($r->deleted, true);
         } catch(Doctrine_Exception $e) {
             $this->fail();
diff --git a/tests_old/Record/InheritanceTestCase.php b/tests_old/Record/InheritanceTestCase.php
index 57dc4a15c..f6c4f6dca 100644
--- a/tests_old/Record/InheritanceTestCase.php
+++ b/tests_old/Record/InheritanceTestCase.php
@@ -4,7 +4,7 @@
  * Doctrine_Record_Inheritance_TestCase
  *
  * This test case demonstrates the use of inheritance involving subclasses of
- * Doctrine_Record.  This type of inheritance is heavily used in sfDoctrine,
+ * Doctrine_Entity.  This type of inheritance is heavily used in sfDoctrine,
  * and as new inheritance-related features get added to Doctrine it seems to
  * be an area where subtle breakage can sneak in.
  *
@@ -49,7 +49,7 @@ class Doctrine_Record_Inheritance_TestCase extends Doctrine_UnitTestCase
         // does it have the appropriate parentage?
         $this->assertTrue($record instanceof PluginSymfonyRecord);
         $this->assertTrue($record instanceof BaseSymfonyRecord);
-        $this->assertTrue($record instanceof Doctrine_Record);
+        $this->assertTrue($record instanceof Doctrine_Entity);
 
         // does it have the expected data?
         $this->assertEqual($record['name'], 'Test me');
diff --git a/tests_old/Record/StateTestCase.php b/tests_old/Record/StateTestCase.php
index 0757c7c89..73c9dbdbe 100644
--- a/tests_old/Record/StateTestCase.php
+++ b/tests_old/Record/StateTestCase.php
@@ -90,79 +90,79 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
         } catch(Doctrine_Record_State_Exception $e) {
             $this->pass();
         }
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
         try {
             $user->state('some unknown state');
             $this->fail();
-        } catch(Doctrine_Record_State_Exception $e) {
+        } catch(Doctrine_Entity_State_Exception $e) {
             $this->pass();
         }
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testAssignDirtyState() 
     {
         $user = new User();
 
-        $user->state(Doctrine_Record::STATE_DIRTY);
+        $user->state(Doctrine_Entity::STATE_DIRTY);
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
         
         $user->state('dirty');
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_DIRTY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_DIRTY);
     }
 
     public function testAssignCleanState() 
     {
         $user = new User();
 
-        $user->state(Doctrine_Record::STATE_CLEAN);
+        $user->state(Doctrine_Entity::STATE_CLEAN);
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
         
         $user->state('clean');
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
     }
 
     public function testAssignTransientCleanState() 
     {
         $user = new User();
 
-        $user->state(Doctrine_Record::STATE_TCLEAN);
+        $user->state(Doctrine_Entity::STATE_TCLEAN);
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
         
         $user->state('tclean');
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testAssignTransientDirtyState() 
     {
         $user = new User();
 
-        $user->state(Doctrine_Record::STATE_TDIRTY);
+        $user->state(Doctrine_Entity::STATE_TDIRTY);
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
         
         $user->state('tdirty');
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TDIRTY);
     }
 
     public function testAssignProxyState()
     {
         $user = new User();
 
-        $user->state(Doctrine_Record::STATE_PROXY);
+        $user->state(Doctrine_Entity::STATE_PROXY);
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
         
         $user->state('proxy');
 
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
     }
 
     public function testProxiesAreAutomaticallyUpdatedWithFetches()
@@ -176,7 +176,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
 
         $user = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = 'someuser'");
         
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_PROXY);
         
         $user2 = $this->connection->queryOne("FROM User u WHERE u.name = 'someuser'");     
 
@@ -208,7 +208,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
         
         // to make sure it is saved correctly
         $user1 = $this->connection->queryOne("FROM User u WHERE u.name = '" . UNAME . "'");
-        $this->assertEqual($user1->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user1->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($user1->name,UNAME) ;
         $this->assertEqual($user1->password,UPWD1) ;
         $this->assertEqual($user1->loginname,ULNAME) ;
@@ -222,7 +222,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
         $user2 = $this->connection->queryOne("SELECT u.name FROM User u WHERE u.name = '" . UNAME . "'");
         
         // the object should be in state proxy with only 'name' fetched ...
-        $this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY);
+        $this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
         $this->assertEqual($user2->name,UNAME) ;
         $this->assertEqual($user2->password,null) ;
         $this->assertEqual($user2->loginname,null) ;
@@ -231,7 +231,7 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
         $user2->password = UPWD2 ;
         
         // now it should be dirty (but may be PDIRTY ... ?)
-        $this->assertEqual($user2->state(),Doctrine_Record::STATE_DIRTY) ;
+        $this->assertEqual($user2->state(),Doctrine_Entity::STATE_DIRTY) ;
         $this->assertEqual($user2->name,UNAME) ;
         $this->assertEqual($user2->password,UPWD2) ;
         $this->assertEqual($user2->loginname,null) ;
@@ -240,11 +240,11 @@ class Doctrine_Record_State_TestCase extends Doctrine_UnitTestCase
         $user2->save() ;
 
         // the logic would suggest the object to go back to PROXY mode (becausse $user2->loginname is null aka not sync with DB)
-        $boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Record::STATE_PROXY) ;
+        $boolState = ($user2->loginname == null) && ($user2->state() === Doctrine_Entity::STATE_PROXY) ;
         // this one will currently fail 
         $this->assertTrue($boolState) ;
         // this will also currently fail (becausse it currently goes back to STATE_CLEAN, which shouldnt be the case)
-        //$this->assertEqual($user2->state(), Doctrine_Record::STATE_PROXY);
+        //$this->assertEqual($user2->state(), Doctrine_Entity::STATE_PROXY);
         $this->assertEqual($user2->name,UNAME) ;
         $this->assertEqual($user2->password,UPWD2) ;
         $this->assertEqual($user2->loginname,null) ;
diff --git a/tests_old/RecordTestCase.php b/tests_old/RecordTestCase.php
index 02ae21afa..b58e71642 100644
--- a/tests_old/RecordTestCase.php
+++ b/tests_old/RecordTestCase.php
@@ -55,7 +55,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $account = $user->Account;
         $account->amount = 1000;
         $this->assertTrue($account instanceof Account);
-        $this->assertEqual($account->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($account->state(), Doctrine_Entity::STATE_TDIRTY);
         $this->assertEqual($account->entity_id->getOid(), $user->getOid());
         $this->assertEqual($account->amount, 1000);
         $this->assertEqual($user->name, "Richard Linklater");
@@ -67,7 +67,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
         $account = $user->Account;
         $this->assertTrue($account instanceof Account);
-        $this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($account->entity_id, $user->id);
         $this->assertEqual($account->amount, 1000);
         $this->assertEqual($user->name, "Richard Linklater");
@@ -80,7 +80,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         
         $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
         $this->connection->unitOfWork->saveAll();
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertTrue($account instanceof Account);
 
         $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
@@ -90,13 +90,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
 
         $user = $user->getRepository()->find($user->id);
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_CLEAN);
 
 
         $account = $user->Account;
         $this->assertTrue($account instanceof Account);
 
-        $this->assertEqual($account->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($account->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($account->getTable()->getColumnNames(), array('id', 'entity_id', 'amount'));
 
         $this->assertEqual($account->entity_id, $user->id);
@@ -272,23 +272,23 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual((array)$record->getTable()->getIdentifier(), array("entity1","entity2"));
         $this->assertEqual($record->getTable()->getIdentifierType(), Doctrine::IDENTIFIER_COMPOSITE);
         $this->assertEqual($record->identifier(), array("entity1" => null, "entity2" => null));
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_TCLEAN);
 
         $record->entity1 = 3;
         $record->entity2 = 4;
         $this->assertEqual($record->entity2, 4);
         $this->assertEqual($record->entity1, 3);
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_TDIRTY);
         $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
 
         $record->save();
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($record->entity2, 4);
         $this->assertEqual($record->entity1, 3);
         $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
 
         $record = $record->getRepository()->find($record->identifier());
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($record->entity2, 4);
         $this->assertEqual($record->entity1, 3);
 
@@ -296,26 +296,26 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
         $record->entity2 = 5;
         $record->entity1 = 2;
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_DIRTY);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_DIRTY);
         $this->assertEqual($record->entity2, 5);
         $this->assertEqual($record->entity1, 2);
         $this->assertEqual($record->identifier(), array("entity1" => 3, "entity2" => 4));
         
         $record->save();
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($record->entity2, 5);
         $this->assertEqual($record->entity1, 2);
         $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
         $record = $record->getRepository()->find($record->identifier());
         
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($record->entity2, 5);
         $this->assertEqual($record->entity1, 2);
         $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
 
         $record->refresh();
 
-        $this->assertEqual($record->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($record->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($record->entity2, 5);
         $this->assertEqual($record->entity1, 2);
         $this->assertEqual($record->identifier(), array("entity1" => 2, "entity2" => 5));
@@ -327,9 +327,9 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
         $coll = $this->connection->query("FROM EntityReference");
         $this->assertTrue($coll[0] instanceof EntityReference);
-        $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertTrue($coll[1] instanceof EntityReference);
-        $this->assertEqual($coll[1]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($coll[1]->state(), Doctrine_Entity::STATE_CLEAN);
 
         $coll = $this->connection->query("FROM EntityReference WHERE EntityReference.entity2 = 5");
         $this->assertEqual($coll->count(), 1);
@@ -351,12 +351,12 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
         $task = new Task();
         $this->assertTrue($task instanceof Task);
-        $this->assertEqual($task->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($task->state(), Doctrine_Entity::STATE_TCLEAN);
         $this->assertTrue($task->Subtask[0] instanceof Task);
 
-        //$this->assertEqual($task->Subtask[0]->state(), Doctrine_Record::STATE_TDIRTY);
+        //$this->assertEqual($task->Subtask[0]->state(), Doctrine_Entity::STATE_TDIRTY);
         $this->assertTrue($task->ResourceAlias[0] instanceof Resource);
-        $this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($task->ResourceAlias[0]->state(), Doctrine_Entity::STATE_TCLEAN);
 
         $task->name = "Task 1";
         $task->ResourceAlias[0]->name = "Resource 1";
@@ -398,13 +398,13 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $table = $this->connection->getClassMetadata("User");
 
         $user = new User();
-        $this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Record::STATE_TCLEAN));
+        $this->assertEqual(Doctrine_Lib::getRecordStateAsString($user->state()), Doctrine_Lib::getRecordStateAsString(Doctrine_Entity::STATE_TCLEAN));
         $user->name = "John Locke";
 
         $this->assertTrue($user->name,"John Locke");
-        $this->assertTrue($user->state() == Doctrine_Record::STATE_TDIRTY);
+        $this->assertTrue($user->state() == Doctrine_Entity::STATE_TDIRTY);
         $user->save();
-        $this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN);
+        $this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
         $this->assertTrue($user->name,"John Locke");
     }
     
@@ -546,10 +546,10 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $this->assertTrue(is_numeric($user->id) && $user->id > 0);
 
         $this->assertTrue($user->getModified() == array());
-        $this->assertTrue($user->state() == Doctrine_Record::STATE_CLEAN);
+        $this->assertTrue($user->state() == Doctrine_Entity::STATE_CLEAN);
 
         $user->delete();
-        $this->assertEqual($user->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($user->state(), Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testUpdate() 
@@ -570,8 +570,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $user = $this->connection->getRepository("User")->find(4);
         $new = $user->copy();
 
-        $this->assertTrue($new instanceof Doctrine_Record);
-        $this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY);
+        $this->assertTrue($new instanceof Doctrine_Entity);
+        $this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
 
         $new = $user->copy();
         $new->save();
@@ -587,8 +587,8 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
         $user = $this->connection->getRepository("User")->find(4);
         $new = $user->copy();
 
-        $this->assertTrue($new instanceof Doctrine_Record);
-        $this->assertTrue($new->state() == Doctrine_Record::STATE_TDIRTY);
+        $this->assertTrue($new instanceof Doctrine_Entity);
+        $this->assertTrue($new->state() == Doctrine_Entity::STATE_TDIRTY);
 
         $new->loginname = 'jackd';
 
@@ -702,7 +702,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
 
         $this->assertTrue($user->Email instanceof Email);
         $this->assertEqual($user->Email->id, $user->email_id);
-        $this->assertEqual($user->Email->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($user->Email->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($user->Email->address, "drinker@drinkmore.info");
         $id = $user->Email->id;
 
@@ -871,7 +871,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
     {
         $user = $this->connection->getRepository("User")->find(4);
 
-        $this->assertTrue($user->Email instanceof Doctrine_Record);
+        $this->assertTrue($user->Email instanceof Doctrine_Entity);
         $this->assertTrue($user->Phonenumber instanceof Doctrine_Collection);
         $this->assertTrue($user->Group instanceof Doctrine_Collection);
 
diff --git a/tests_old/Relation/AccessTestCase.php b/tests_old/Relation/AccessTestCase.php
index 82f3ebea5..0dfe5419e 100644
--- a/tests_old/Relation/AccessTestCase.php
+++ b/tests_old/Relation/AccessTestCase.php
@@ -81,7 +81,7 @@ class Doctrine_Relation_Access_TestCase extends Doctrine_UnitTestCase {
     public function testOneToOneAggregateRelationFetching() {
         $coll = $this->connection->query("FROM File_Owner.Data_File WHERE File_Owner.name = 'owner1'");
         $this->assertTrue(count($coll) == 1);
-        $this->assertTrue($coll[0] instanceof Doctrine_Record);
+        $this->assertTrue($coll[0] instanceof Doctrine_Entity);
 
         $this->assertEqual($coll[0]->id, 1);
     }
diff --git a/tests_old/Relation/NestTestCase.php b/tests_old/Relation/NestTestCase.php
index 263f94c10..eac03071c 100644
--- a/tests_old/Relation/NestTestCase.php
+++ b/tests_old/Relation/NestTestCase.php
@@ -48,8 +48,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
         $this->assertTrue($e->Entity[0] instanceof Entity);
         $this->assertTrue($e->Entity[1] instanceof Entity);
 
-        $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TCLEAN);
-        $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TCLEAN);
+        $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TCLEAN);
+        $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TCLEAN);
         
         $e->Entity[0]->name = 'Friend 1';
         $e->Entity[1]->name = 'Friend 2';
@@ -69,8 +69,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($e->Entity[1]->Entity[0]->name, 'Friend 2 1');
         $this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 2');
 
-        $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_TDIRTY);
-        $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_TDIRTY);
+        $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_TDIRTY);
+        $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_TDIRTY);
 
         $count = count($this->conn);
 
@@ -83,7 +83,7 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
         $this->connection->clear();
 
         $e = $this->conn->queryOne('FROM Entity e LEFT JOIN e.Entity e2 LEFT JOIN e2.Entity e3 WHERE e.id = 1 ORDER BY e.name, e2.name, e3.name');
-        $this->assertEqual($e->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($e->state(), Doctrine_Entity::STATE_CLEAN);
 
         $this->assertTrue($e->Entity[0] instanceof Entity);
         $this->assertTrue($e->Entity[1] instanceof Entity);
@@ -99,8 +99,8 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($e->Entity[1]->Entity[1]->name, 'Friend 2 1');
         $this->assertEqual($e->Entity[1]->Entity[2]->name, 'Friend 2 2');
 
-        $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
 
         $this->assertTrue(is_numeric($e->id));
 
@@ -135,12 +135,12 @@ class Doctrine_Relation_Nest_TestCase extends Doctrine_UnitTestCase
         $this->assertEqual($e->Entity[1]->Entity[0]->name, "Entity test");
         $this->assertEqual($e->Entity[1]->Entity[1]->name, "Friend 2 1");
 
-        $this->assertEqual($e->Entity[0]->state(), Doctrine_Record::STATE_CLEAN);
-        $this->assertEqual($e->Entity[1]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($e->Entity[0]->state(), Doctrine_Entity::STATE_CLEAN);
+        $this->assertEqual($e->Entity[1]->state(), Doctrine_Entity::STATE_CLEAN);
         
         $coll = $this->connection->query("FROM Entity WHERE Entity.name = 'Friend 1'");
         $this->assertEqual($coll->count(), 1);
-        $this->assertEqual($coll[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($coll[0]->state(), Doctrine_Entity::STATE_CLEAN);
         
         $this->assertEqual($coll[0]->name, "Friend 1");
         
diff --git a/tests_old/TableTestCase.php b/tests_old/TableTestCase.php
index 72f043653..5a6baefd3 100644
--- a/tests_old/TableTestCase.php
+++ b/tests_old/TableTestCase.php
@@ -149,18 +149,18 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
     public function testCreate() 
     {
         $record = $this->objTable->create();
-        $this->assertTrue($record instanceof Doctrine_Record);
-        $this->assertTrue($record->state() == Doctrine_Record::STATE_TCLEAN);
+        $this->assertTrue($record instanceof Doctrine_Entity);
+        $this->assertTrue($record->state() == Doctrine_Entity::STATE_TCLEAN);
     }
 
     public function testFind() 
     {
         $record = $this->objTable->find(4);
-        $this->assertTrue($record instanceof Doctrine_Record);
+        $this->assertTrue($record instanceof Doctrine_Entity);
         
         try {
             $record = $this->objTable->find('4');
-            $this->assertTrue($record instanceof Doctrine_Record);
+            $this->assertTrue($record instanceof Doctrine_Entity);
         } catch(Exception $e) {
             $this->assertTrue(false);
         }
@@ -171,7 +171,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
             $this->assertTrue( ! is_object($record));
             $this->assertTrue(array_key_exists('id', $record));
             $this->assertTrue(array_key_exists('name', $record));
-            $this->assertTrue( ! $record instanceof Doctrine_Record);
+            $this->assertTrue( ! $record instanceof Doctrine_Entity);
         } catch(Exception $e) {
             $this->assertTrue(false);
         }
@@ -221,7 +221,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase
     public function testGetProxy() 
     {
         $user = $this->objTable->getProxy(4);
-        $this->assertTrue($user instanceof Doctrine_Record);
+        $this->assertTrue($user instanceof Doctrine_Entity);
 
         try {
             $record = $this->objTable->find(123);
diff --git a/tests_old/Ticket/438TestCase.php b/tests_old/Ticket/438TestCase.php
index 25f9d6ccb..e108765c2 100644
--- a/tests_old/Ticket/438TestCase.php
+++ b/tests_old/Ticket/438TestCase.php
@@ -107,7 +107,7 @@ class Doctrine_Ticket_438_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T438_Student extends Doctrine_Record
+class T438_Student extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -119,7 +119,7 @@ class T438_Student extends Doctrine_Record
 }
 
 
-class T438_Course extends Doctrine_Record
+class T438_Course extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -130,7 +130,7 @@ class T438_Course extends Doctrine_Record
   }
 }
 
-class T438_StudentCourse extends Doctrine_Record
+class T438_StudentCourse extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/480TestCase.php b/tests_old/Ticket/480TestCase.php
index e0a521ba0..35a356b4e 100644
--- a/tests_old/Ticket/480TestCase.php
+++ b/tests_old/Ticket/480TestCase.php
@@ -31,7 +31,7 @@
  * @version     $Revision$
  */
 
-class stComment extends Doctrine_Record
+class stComment extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Ticket/626BTestCase.php b/tests_old/Ticket/626BTestCase.php
index 8e7c8c960..d50ea808e 100644
--- a/tests_old/Ticket/626BTestCase.php
+++ b/tests_old/Ticket/626BTestCase.php
@@ -88,7 +88,7 @@ class Doctrine_Ticket_626B_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T626B_Student extends Doctrine_Record
+class T626B_Student extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -103,7 +103,7 @@ class T626B_Student extends Doctrine_Record
   }
 }
 
-class T626_Group extends Doctrine_Record
+class T626_Group extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -117,7 +117,7 @@ class T626_Group extends Doctrine_Record
 }
 
 
-class T626_Course extends Doctrine_Record
+class T626_Course extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -129,7 +129,7 @@ class T626_Course extends Doctrine_Record
   }
 }
 
-class T626B_StudentCourse extends Doctrine_Record
+class T626B_StudentCourse extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/626CTestCase.php b/tests_old/Ticket/626CTestCase.php
index 30ebd3c26..acda31937 100644
--- a/tests_old/Ticket/626CTestCase.php
+++ b/tests_old/Ticket/626CTestCase.php
@@ -62,7 +62,7 @@ class Doctrine_Ticket_626C_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T626C_Student1 extends Doctrine_Record
+class T626C_Student1 extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -73,7 +73,7 @@ class T626C_Student1 extends Doctrine_Record
   }
 }
 
-class T626C_Student2 extends Doctrine_Record
+class T626C_Student2 extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/626DTestCase.php b/tests_old/Ticket/626DTestCase.php
index a2388c215..6dbefd001 100644
--- a/tests_old/Ticket/626DTestCase.php
+++ b/tests_old/Ticket/626DTestCase.php
@@ -46,7 +46,7 @@ class Doctrine_Ticket_626D_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T626D_Student1 extends Doctrine_Record
+class T626D_Student1 extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/638TestCase.php b/tests_old/Ticket/638TestCase.php
index 8ef392d6d..2fbe12ce2 100644
--- a/tests_old/Ticket/638TestCase.php
+++ b/tests_old/Ticket/638TestCase.php
@@ -105,7 +105,7 @@ class Doctrine_Ticket_638_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T638_Student extends Doctrine_Record
+class T638_Student extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -118,7 +118,7 @@ class T638_Student extends Doctrine_Record
   
 }
 
-class T638_Course extends Doctrine_Record
+class T638_Course extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -134,7 +134,7 @@ class T638_Course extends Doctrine_Record
   }
 }
 
-class T638_StudentCourse extends Doctrine_Record
+class T638_StudentCourse extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/642TestCase.php b/tests_old/Ticket/642TestCase.php
index bc694d9c7..8ad705be9 100644
--- a/tests_old/Ticket/642TestCase.php
+++ b/tests_old/Ticket/642TestCase.php
@@ -50,7 +50,7 @@ class Doctrine_Ticket_642_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class stDummyObj extends Doctrine_Record
+class stDummyObj extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Ticket/673TestCase.php b/tests_old/Ticket/673TestCase.php
index c324e3672..0624edb37 100644
--- a/tests_old/Ticket/673TestCase.php
+++ b/tests_old/Ticket/673TestCase.php
@@ -58,7 +58,7 @@ class Doctrine_Ticket_673_TestCase extends Doctrine_UnitTestCase
 }
 
 
-class T673_Student extends Doctrine_Record
+class T673_Student extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/697TestCase.php b/tests_old/Ticket/697TestCase.php
index c6d2cd04c..eca87108e 100644
--- a/tests_old/Ticket/697TestCase.php
+++ b/tests_old/Ticket/697TestCase.php
@@ -36,7 +36,7 @@ class Doctrine_Ticket_697_TestCase extends Doctrine_UnitTestCase
     }
 }
 
-class T697_Person extends Doctrine_Record
+class T697_Person extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/Ticket/741TestCase.php b/tests_old/Ticket/741TestCase.php
index c265e651f..42e188522 100644
--- a/tests_old/Ticket/741TestCase.php
+++ b/tests_old/Ticket/741TestCase.php
@@ -29,7 +29,7 @@ class Doctrine_Ticket_741_TestCase extends Doctrine_UnitTestCase
 
 
 
-class Parent741 extends Doctrine_Record
+class Parent741 extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
@@ -44,7 +44,7 @@ class Parent741 extends Doctrine_Record
   }
 }
 
-class Child741 extends Doctrine_Record
+class Child741 extends Doctrine_Entity
 {
   public static function initMetadata($class)
   {
diff --git a/tests_old/Ticket/749TestCase.php b/tests_old/Ticket/749TestCase.php
index 98fa153da..046dbcac1 100644
--- a/tests_old/Ticket/749TestCase.php
+++ b/tests_old/Ticket/749TestCase.php
@@ -84,7 +84,7 @@ class Doctrine_Ticket_749_TestCase extends Doctrine_UnitTestCase
     }
 }
 
-class Parent749 extends Doctrine_Record
+class Parent749 extends Doctrine_Entity
 {
   public function setTableDefinition()
   {
@@ -124,7 +124,7 @@ class Record749 extends Parent749
   }
 }
 
-class RelatedRecord749 extends Doctrine_Record
+class RelatedRecord749 extends Doctrine_Entity
 {
   public function setTableDefinition()
   {
diff --git a/tests_old/Ticket/912TestCase.php b/tests_old/Ticket/912TestCase.php
index e5a0103df..b448d9090 100644
--- a/tests_old/Ticket/912TestCase.php
+++ b/tests_old/Ticket/912TestCase.php
@@ -96,7 +96,7 @@ class Doctrine_Ticket_912_TestCase extends Doctrine_UnitTestCase {
  * This class has been auto-generated by the Doctrine ORM Framework
  */
 
-class ticket912_Resume extends Doctrine_Record
+class ticket912_Resume extends Doctrine_Entity
 {
     public static function initMetadata($mapping)
     {
@@ -124,7 +124,7 @@ class ticket912_Resume extends Doctrine_Record
 /**
  *  First level one to one relation class Language
  */
-class ticket912_Person extends Doctrine_Record
+class ticket912_Person extends Doctrine_Entity
 {	
     public static function initMetadata($mapping)
     {
@@ -144,7 +144,7 @@ class ticket912_Person extends Doctrine_Record
  *  Second level one to many relation class ResumeHasLanguageLanguage
  */
 
-class ticket912_ResumeHasLanguage extends Doctrine_Record
+class ticket912_ResumeHasLanguage extends Doctrine_Entity
 {
     public static function initMetadata($mapping)
     {
@@ -192,7 +192,7 @@ class ticket912_ResumeHasLanguage extends Doctrine_Record
 /**
  *  Third level one to one relation class Language
  */
-class ticket912_Language extends Doctrine_Record
+class ticket912_Language extends Doctrine_Entity
 {
     public static function initMetadata($mapping)
     {
@@ -214,7 +214,7 @@ class ticket912_Language extends Doctrine_Record
  * Third level one to one relation class Language
  */
 
-class ticket912_LanguageLevel extends Doctrine_Record
+class ticket912_LanguageLevel extends Doctrine_Entity
 {
     public static function initMetadata($mapping)
     {
diff --git a/tests_old/ValidatorTestCase.php b/tests_old/ValidatorTestCase.php
index 1c4636e03..75d8e7fc8 100644
--- a/tests_old/ValidatorTestCase.php
+++ b/tests_old/ValidatorTestCase.php
@@ -235,7 +235,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
 
     /**
      * Tests whether the validate() callback works correctly
-     * in descendants of Doctrine_Record.
+     * in descendants of Doctrine_Entity.
      */
     public function testValidationHooks() 
     {
@@ -282,7 +282,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase
 
     /**
      * Tests whether the validateOnInsert() callback works correctly
-     * in descendants of Doctrine_Record.
+     * in descendants of Doctrine_Entity.
      */
     public function testHookValidateOnInsert() 
     {
diff --git a/tests_old/ViewTestCase.php b/tests_old/ViewTestCase.php
index 3fb0ba8b1..f64ff118b 100644
--- a/tests_old/ViewTestCase.php
+++ b/tests_old/ViewTestCase.php
@@ -60,7 +60,7 @@ class Doctrine_View_TestCase extends Doctrine_UnitTestCase
         $this->assertTrue($users instanceof Doctrine_Collection);
         $this->assertEqual($users->count(), 8);
         $this->assertEqual($users[0]->name, 'zYne');
-        $this->assertEqual($users[0]->state(), Doctrine_Record::STATE_CLEAN);
+        $this->assertEqual($users[0]->state(), Doctrine_Entity::STATE_CLEAN);
         $this->assertEqual($count, $this->conn->count());
 
         $success = true;
diff --git a/tests_old/models/Account.php b/tests_old/models/Account.php
index adf2f7628..b35f54394 100644
--- a/tests_old/models/Account.php
+++ b/tests_old/models/Account.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 32);
         $class->setColumn('user_id', 'integer', 11);
diff --git a/tests_old/models/App_Category.php b/tests_old/models/App_Category.php
index 5d5caaeb5..977a4112c 100644
--- a/tests_old/models/App_Category.php
+++ b/tests_old/models/App_Category.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 32);
         $class->setColumn('parent_id', 'integer');
diff --git a/tests_old/models/App_User.php b/tests_old/models/App_User.php
index e70d731c3..d23701ed5 100644
--- a/tests_old/models/App_User.php
+++ b/tests_old/models/App_User.php
@@ -1,5 +1,5 @@
 setColumn('first_name', 'string', 32);
         $class->setColumn('last_name', 'string', 32);
diff --git a/tests_old/models/Assignment.php b/tests_old/models/Assignment.php
index 0cc880cb4..aec87421f 100644
--- a/tests_old/models/Assignment.php
+++ b/tests_old/models/Assignment.php
@@ -1,5 +1,5 @@
 setColumn('task_id', 'integer'); 
        $class->setColumn('resource_id', 'integer'); 
diff --git a/tests_old/models/Auth.php b/tests_old/models/Auth.php
index 04730307c..560380a6b 100644
--- a/tests_old/models/Auth.php
+++ b/tests_old/models/Auth.php
@@ -1,5 +1,5 @@
 hasMany('[Component]TagTemplate as Tag');
     }
 }
-class TagTemplate extends Doctrine_Record
+class TagTemplate extends Doctrine_Entity
 {
     public static function initMetadata($class)
     {
diff --git a/tests_old/models/BlogTag.php b/tests_old/models/BlogTag.php
index d8b64cb81..33a6a1e9b 100644
--- a/tests_old/models/BlogTag.php
+++ b/tests_old/models/BlogTag.php
@@ -1,5 +1,5 @@
 setColumn('position', 'integer');
         $class->setColumn('category_id', 'integer');
diff --git a/tests_old/models/Book.php b/tests_old/models/Book.php
index 3864f4fe5..3d99d0c25 100644
--- a/tests_old/models/Book.php
+++ b/tests_old/models/Book.php
@@ -1,5 +1,5 @@
 setColumn('is_working', 'boolean');
         $class->setColumn('is_working_notnull', 'boolean', 1, array('default' => false, 'notnull' => true));
diff --git a/tests_old/models/CPK_Association.php b/tests_old/models/CPK_Association.php
index 52309dab4..63a031529 100644
--- a/tests_old/models/CPK_Association.php
+++ b/tests_old/models/CPK_Association.php
@@ -1,5 +1,5 @@
 setColumn('test1_id', 'integer', 11, 'primary');
         $class->setColumn('test2_id', 'integer', 11, 'primary');
diff --git a/tests_old/models/CPK_Test.php b/tests_old/models/CPK_Test.php
index 726a8c34b..2c53541e1 100644
--- a/tests_old/models/CPK_Test.php
+++ b/tests_old/models/CPK_Test.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 255);
         $class->hasMany('CPK_Test2 as Test', array('local' => 'test_id', 'foreign' => 'test2_id', 'refClass' => 'CPK_Association'));
diff --git a/tests_old/models/CPK_Test2.php b/tests_old/models/CPK_Test2.php
index 62f68eb8d..92c75f0a9 100644
--- a/tests_old/models/CPK_Test2.php
+++ b/tests_old/models/CPK_Test2.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 255);
         $class->hasMany('CPK_Test as Test', array('local' => 'test2_id', 'test1_id', 'refClass' => 'CPK_Association'));
diff --git a/tests_old/models/CascadeDeleteRelatedTest.php b/tests_old/models/CascadeDeleteRelatedTest.php
index 03d1bc8b8..d0752e7fa 100644
--- a/tests_old/models/CascadeDeleteRelatedTest.php
+++ b/tests_old/models/CascadeDeleteRelatedTest.php
@@ -1,5 +1,5 @@
 setColumn('position', 'integer');
         $class->setColumn('name', 'string', 255);
diff --git a/tests_old/models/CheckConstraintTest.php b/tests_old/models/CheckConstraintTest.php
index caac2c8cf..6f3d22006 100644
--- a/tests_old/models/CheckConstraintTest.php
+++ b/tests_old/models/CheckConstraintTest.php
@@ -1,5 +1,5 @@
 setTableName('coverage_codes');
diff --git a/tests_old/models/CustomPK.php b/tests_old/models/CustomPK.php
index bb1c39865..1f0e7c43b 100644
--- a/tests_old/models/CustomPK.php
+++ b/tests_old/models/CustomPK.php
@@ -1,5 +1,5 @@
 setColumn('uid', 'integer',11, array('autoincrement' => true, 'primary' => true));
         $class->setColumn('name', 'string',255);
diff --git a/tests_old/models/CustomSequenceRecord.php b/tests_old/models/CustomSequenceRecord.php
index 2ed58cf18..e712a70a6 100644
--- a/tests_old/models/CustomSequenceRecord.php
+++ b/tests_old/models/CustomSequenceRecord.php
@@ -1,5 +1,5 @@
 setColumn('id', 'integer', null, array('primary', 'sequence' => 'custom_seq'));
diff --git a/tests_old/models/Data_File.php b/tests_old/models/Data_File.php
index 8ca1c1af5..97afb672a 100644
--- a/tests_old/models/Data_File.php
+++ b/tests_old/models/Data_File.php
@@ -1,5 +1,5 @@
 setColumn('filename', 'string');
         $class->setColumn('file_owner_id', 'integer');
diff --git a/tests_old/models/DateTest.php b/tests_old/models/DateTest.php
index e04259a00..eabbbad6a 100644
--- a/tests_old/models/DateTest.php
+++ b/tests_old/models/DateTest.php
@@ -1,5 +1,5 @@
 setColumn('date', 'date', 20); 
     }
diff --git a/tests_old/models/Description.php b/tests_old/models/Description.php
index ad919165d..fd51afe8c 100644
--- a/tests_old/models/Description.php
+++ b/tests_old/models/Description.php
@@ -1,5 +1,5 @@
 setColumn('description', 'string',3000);
         $class->setColumn('file_md5', 'string',32);
diff --git a/tests_old/models/Element.php b/tests_old/models/Element.php
index 727e4becb..bddf40c41 100644
--- a/tests_old/models/Element.php
+++ b/tests_old/models/Element.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 100);
         $class->setColumn('parent_id', 'integer');
diff --git a/tests_old/models/Email.php b/tests_old/models/Email.php
index b2b62f550..f8d170c34 100644
--- a/tests_old/models/Email.php
+++ b/tests_old/models/Email.php
@@ -1,5 +1,5 @@
 setColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
diff --git a/tests_old/models/EnumTest2.php b/tests_old/models/EnumTest2.php
index fe9d71901..1989c734f 100644
--- a/tests_old/models/EnumTest2.php
+++ b/tests_old/models/EnumTest2.php
@@ -1,5 +1,5 @@
 setColumn('status', 'enum', 11, array('values' => array('open', 'verified', 'closed')));
diff --git a/tests_old/models/EnumTest3.php b/tests_old/models/EnumTest3.php
index 53ae609f9..e241e2b4f 100644
--- a/tests_old/models/EnumTest3.php
+++ b/tests_old/models/EnumTest3.php
@@ -1,5 +1,5 @@
 setColumn('text', 'string', 10, array('primary' => true));
diff --git a/tests_old/models/Error.php b/tests_old/models/Error.php
index 1edf191a8..091d0bd24 100644
--- a/tests_old/models/Error.php
+++ b/tests_old/models/Error.php
@@ -1,5 +1,5 @@
 setColumn('message', 'string',200);
         $class->setColumn('code', 'integer',11);
diff --git a/tests_old/models/EventListenerChainTest.php b/tests_old/models/EventListenerChainTest.php
index 792e961dd..6570a4c30 100644
--- a/tests_old/models/EventListenerChainTest.php
+++ b/tests_old/models/EventListenerChainTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 100);
diff --git a/tests_old/models/EventListenerTest.php b/tests_old/models/EventListenerTest.php
index bbaa6be53..230bb9cf6 100644
--- a/tests_old/models/EventListenerTest.php
+++ b/tests_old/models/EventListenerTest.php
@@ -1,5 +1,5 @@
 setColumn("name", "string", 100);
         $class->setColumn("password", "string", 8);
diff --git a/tests_old/models/FieldNameTest.php b/tests_old/models/FieldNameTest.php
index 736e0c240..0ff090e21 100644
--- a/tests_old/models/FieldNameTest.php
+++ b/tests_old/models/FieldNameTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 255);
         $class->hasOne('Data_File', array('local' => 'id', 'foreign' => 'file_owner_id'));
diff --git a/tests_old/models/FilterTest.php b/tests_old/models/FilterTest.php
index cdedf3204..ec98e4a19 100644
--- a/tests_old/models/FilterTest.php
+++ b/tests_old/models/FilterTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string',100);
         $class->hasMany('FilterTest2 as filtered', array('local' => 'id', 'foreign' => 'test1_id'));
diff --git a/tests_old/models/FilterTest2.php b/tests_old/models/FilterTest2.php
index fb0080b9f..a527d8b35 100644
--- a/tests_old/models/FilterTest2.php
+++ b/tests_old/models/FilterTest2.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string',100);
         $class->setColumn('test1_id', 'integer');
diff --git a/tests_old/models/FooBarRecord.php b/tests_old/models/FooBarRecord.php
index 423b2555f..c067a6470 100644
--- a/tests_old/models/FooBarRecord.php
+++ b/tests_old/models/FooBarRecord.php
@@ -1,5 +1,5 @@
 setColumn('category_id', 'integer', 10);
         $class->setColumn('name', 'string', 100);
diff --git a/tests_old/models/Forum_Category.php b/tests_old/models/Forum_Category.php
index 00edd6293..d57432e9d 100644
--- a/tests_old/models/Forum_Category.php
+++ b/tests_old/models/Forum_Category.php
@@ -1,5 +1,5 @@
 setColumn('root_category_id', 'integer', 10);
         $class->setColumn('parent_category_id', 'integer', 10);
diff --git a/tests_old/models/Forum_Entry.php b/tests_old/models/Forum_Entry.php
index e88730468..19538c082 100644
--- a/tests_old/models/Forum_Entry.php
+++ b/tests_old/models/Forum_Entry.php
@@ -1,5 +1,5 @@
 setColumn('author', 'string', 50); 
         $class->setColumn('topic', 'string', 100);
diff --git a/tests_old/models/Forum_Thread.php b/tests_old/models/Forum_Thread.php
index 19f8f1408..691b088f1 100644
--- a/tests_old/models/Forum_Thread.php
+++ b/tests_old/models/Forum_Thread.php
@@ -1,5 +1,5 @@
 setColumn('board_id', 'integer', 10);
         $class->setColumn('updated', 'integer', 10);
diff --git a/tests_old/models/Groupuser.php b/tests_old/models/Groupuser.php
index 899693dd7..1da05f2da 100644
--- a/tests_old/models/Groupuser.php
+++ b/tests_old/models/Groupuser.php
@@ -1,5 +1,5 @@
 setColumn('gzip', 'gzip', 100000);
     }
diff --git a/tests_old/models/I18nTest.php b/tests_old/models/I18nTest.php
index b6e6d0bbd..74987f41a 100644
--- a/tests_old/models/I18nTest.php
+++ b/tests_old/models/I18nTest.php
@@ -1,5 +1,5 @@
 setColumn('c1_id', 'integer');
         $class->setColumn('c2_id', 'integer');
diff --git a/tests_old/models/JC2.php b/tests_old/models/JC2.php
index 8ee301049..09b3c47e5 100644
--- a/tests_old/models/JC2.php
+++ b/tests_old/models/JC2.php
@@ -1,5 +1,5 @@
 setColumn('c1_id', 'integer');
         $class->setColumn('c2_id', 'integer');
diff --git a/tests_old/models/JC3.php b/tests_old/models/JC3.php
index 6c6dcbaed..c9db796da 100644
--- a/tests_old/models/JC3.php
+++ b/tests_old/models/JC3.php
@@ -1,5 +1,5 @@
 setColumn('c1_id', 'integer');
         $class->setColumn('c2_id', 'integer');
diff --git a/tests_old/models/LiabilityCodeN.php b/tests_old/models/LiabilityCodeN.php
index efda2e0bd..dcd2a22c0 100644
--- a/tests_old/models/LiabilityCodeN.php
+++ b/tests_old/models/LiabilityCodeN.php
@@ -1,5 +1,5 @@
 setTableName('liability_codes');
diff --git a/tests_old/models/Location.php b/tests_old/models/Location.php
index 108b15223..27a00d91a 100644
--- a/tests_old/models/Location.php
+++ b/tests_old/models/Location.php
@@ -1,5 +1,5 @@
 setColumn('stamp', 'timestamp');
         $class->setColumn('status_id', 'integer');
diff --git a/tests_old/models/Log_Status.php b/tests_old/models/Log_Status.php
index 6459f770c..51dcbd1e8 100644
--- a/tests_old/models/Log_Status.php
+++ b/tests_old/models/Log_Status.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 255);
     }
diff --git a/tests_old/models/M2MTest.php b/tests_old/models/M2MTest.php
index 7994e5367..65f88c9ff 100644
--- a/tests_old/models/M2MTest.php
+++ b/tests_old/models/M2MTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 200);
         $class->setColumn('child_id', 'integer');
diff --git a/tests_old/models/M2MTest2.php b/tests_old/models/M2MTest2.php
index c39b28e19..0ccc5a0ca 100644
--- a/tests_old/models/M2MTest2.php
+++ b/tests_old/models/M2MTest2.php
@@ -1,5 +1,5 @@
 setColumn('oid', 'integer', 11, array('autoincrement', 'primary'));
         $class->setColumn('name', 'string', 20);
diff --git a/tests_old/models/MigrationTest.php b/tests_old/models/MigrationTest.php
index 72023b1ff..464caa9bb 100644
--- a/tests_old/models/MigrationTest.php
+++ b/tests_old/models/MigrationTest.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string');
         $this->hasColumn('user_id', 'integer');
diff --git a/tests_old/models/MyOtherThing.php b/tests_old/models/MyOtherThing.php
index 8a43926c3..84b26cce1 100644
--- a/tests_old/models/MyOtherThing.php
+++ b/tests_old/models/MyOtherThing.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string');
         $this->hasColumn('user_id', 'integer');
diff --git a/tests_old/models/MyUser.php b/tests_old/models/MyUser.php
index b9ff46de6..d9cc791e0 100644
--- a/tests_old/models/MyUser.php
+++ b/tests_old/models/MyUser.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string');
     }
diff --git a/tests_old/models/MyUser2.php b/tests_old/models/MyUser2.php
index 8e98a59eb..21e5362b7 100644
--- a/tests_old/models/MyUser2.php
+++ b/tests_old/models/MyUser2.php
@@ -1,5 +1,5 @@
 setColumn('user_id', 'integer');
         $class->setColumn('one_thing_id', 'integer');
diff --git a/tests_old/models/MyUserOtherThing.php b/tests_old/models/MyUserOtherThing.php
index cbe702483..cf31c37c4 100644
--- a/tests_old/models/MyUserOtherThing.php
+++ b/tests_old/models/MyUserOtherThing.php
@@ -1,5 +1,5 @@
 hasColumn('user_id', 'integer');
         $this->hasColumn('other_thing_id', 'integer');
diff --git a/tests_old/models/MysqlGroup.php b/tests_old/models/MysqlGroup.php
index acc7d81eb..0afbadaf2 100644
--- a/tests_old/models/MysqlGroup.php
+++ b/tests_old/models/MysqlGroup.php
@@ -1,5 +1,5 @@
 actAs('NestedSet');
diff --git a/tests_old/models/NotNullTest.php b/tests_old/models/NotNullTest.php
index feb3b471f..878eca43d 100644
--- a/tests_old/models/NotNullTest.php
+++ b/tests_old/models/NotNullTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 100, array('notnull' => true));
         $class->setColumn('type', 'integer', 11);          	
diff --git a/tests_old/models/ORM_AccessControl.php b/tests_old/models/ORM_AccessControl.php
index 9442d8789..b625a0a8b 100644
--- a/tests_old/models/ORM_AccessControl.php
+++ b/tests_old/models/ORM_AccessControl.php
@@ -1,5 +1,5 @@
 setTableName('test_entries');
         $this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
diff --git a/tests_old/models/ORM_TestItem.php b/tests_old/models/ORM_TestItem.php
index 93b9c8bcd..cdac98d7d 100644
--- a/tests_old/models/ORM_TestItem.php
+++ b/tests_old/models/ORM_TestItem.php
@@ -1,5 +1,5 @@
 setTableName('test_items');
         $this->hasColumn('id', 'integer', 11, 'autoincrement|primary');
diff --git a/tests_old/models/Package.php b/tests_old/models/Package.php
index fda314f3d..2cc0a2844 100644
--- a/tests_old/models/Package.php
+++ b/tests_old/models/Package.php
@@ -1,5 +1,5 @@
 setColumn('description', 'string', 255);
         $class->hasMany('PackageVersion as Version', array('local' => 'id', 'foreign' => 'package_id'));
diff --git a/tests_old/models/PackageVersion.php b/tests_old/models/PackageVersion.php
index 45aaf90ae..8c60e2a60 100644
--- a/tests_old/models/PackageVersion.php
+++ b/tests_old/models/PackageVersion.php
@@ -1,5 +1,5 @@
 hasColumn('package_id', 'integer');
         $this->hasColumn('description', 'string', 255);
diff --git a/tests_old/models/PackageVersionNotes.php b/tests_old/models/PackageVersionNotes.php
index 6e880def9..f7b7264a2 100644
--- a/tests_old/models/PackageVersionNotes.php
+++ b/tests_old/models/PackageVersionNotes.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 100);
         $class->hasMany('Tag', array('local' => 'photo_id', 'foreign' => 'tag_id', 'refClass' => 'Phototag'));
diff --git a/tests_old/models/Phototag.php b/tests_old/models/Phototag.php
index c7a97e0e2..940f37cb9 100644
--- a/tests_old/models/Phototag.php
+++ b/tests_old/models/Phototag.php
@@ -1,5 +1,5 @@
 setColumn('photo_id', 'integer');
         $class->setColumn('tag_id', 'integer');
diff --git a/tests_old/models/Policy.php b/tests_old/models/Policy.php
index b68e83f02..884c629e9 100644
--- a/tests_old/models/Policy.php
+++ b/tests_old/models/Policy.php
@@ -1,5 +1,5 @@
 setTableName('policy_codes');
diff --git a/tests_old/models/PolicyN.php b/tests_old/models/PolicyN.php
index 11e10617d..ff6fcc7c8 100644
--- a/tests_old/models/PolicyN.php
+++ b/tests_old/models/PolicyN.php
@@ -1,5 +1,5 @@
 setTableName('policies');
diff --git a/tests_old/models/QueryTest_Board.php b/tests_old/models/QueryTest_Board.php
index 9b730ff47..a8c7698a9 100644
--- a/tests_old/models/QueryTest_Board.php
+++ b/tests_old/models/QueryTest_Board.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string', 200);
     }
diff --git a/tests_old/models/RTC2.php b/tests_old/models/RTC2.php
index d66d21518..a5c77312e 100644
--- a/tests_old/models/RTC2.php
+++ b/tests_old/models/RTC2.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string', 200);
     }
diff --git a/tests_old/models/RTC3.php b/tests_old/models/RTC3.php
index e93b43e28..e0b23f671 100644
--- a/tests_old/models/RTC3.php
+++ b/tests_old/models/RTC3.php
@@ -1,5 +1,5 @@
 hasColumn('name', 'string', 200);
     }
diff --git a/tests_old/models/RTC4.php b/tests_old/models/RTC4.php
index cbc1353ce..62568a5e1 100644
--- a/tests_old/models/RTC4.php
+++ b/tests_old/models/RTC4.php
@@ -1,5 +1,5 @@
 setColumn('oid', 'integer', 11, array('autoincrement', 'primary'));  
         $class->setColumn('name', 'string', 20);
diff --git a/tests_old/models/RateN.php b/tests_old/models/RateN.php
index c2db3ae65..5766d4163 100644
--- a/tests_old/models/RateN.php
+++ b/tests_old/models/RateN.php
@@ -1,5 +1,5 @@
 setTableName('rates');
diff --git a/tests_old/models/Rec1.php b/tests_old/models/Rec1.php
index 7ca223d3b..9d57bd47a 100644
--- a/tests_old/models/Rec1.php
+++ b/tests_old/models/Rec1.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 200);
         $class->setColumn('country_id', 'integer');
diff --git a/tests_old/models/Record_Country.php b/tests_old/models/Record_Country.php
index 5cc0e9cdc..5483bc7ea 100644
--- a/tests_old/models/Record_Country.php
+++ b/tests_old/models/Record_Country.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 200);
         $class->hasMany('Record_City as City', array('local' => 'id', 'foreign' => 'country_id'));
diff --git a/tests_old/models/Record_District.php b/tests_old/models/Record_District.php
index 69fc91371..c81f7072f 100644
--- a/tests_old/models/Record_District.php
+++ b/tests_old/models/Record_District.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string', 200);
     } 
diff --git a/tests_old/models/RelationTest.php b/tests_old/models/RelationTest.php
index d251b2c0f..29edf4cf2 100644
--- a/tests_old/models/RelationTest.php
+++ b/tests_old/models/RelationTest.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string',100);
       $class->hasMany('Task as TaskAlias', array('local' => 'resource_id', 'foreign' => 'task_id', 'refClass' => 'Assignment'));
diff --git a/tests_old/models/ResourceReference.php b/tests_old/models/ResourceReference.php
index a38a2af0e..5c3eb24ff 100644
--- a/tests_old/models/ResourceReference.php
+++ b/tests_old/models/ResourceReference.php
@@ -1,5 +1,5 @@
 setColumn('type_id', 'integer');
        $class->setColumn('resource_id', 'integer');
diff --git a/tests_old/models/ResourceType.php b/tests_old/models/ResourceType.php
index 44405beb6..e26f0e34a 100644
--- a/tests_old/models/ResourceType.php
+++ b/tests_old/models/ResourceType.php
@@ -1,5 +1,5 @@
 setColumn('type', 'string',100);
         $class->hasMany('Resource as ResourceAlias', array('local' => 'type_id', 'foreign' => 'resource_id', 'refClass' => 'ResourceReference'));
diff --git a/tests_old/models/Role.php b/tests_old/models/Role.php
index c7a667bca..b52ab15e6 100644
--- a/tests_old/models/Role.php
+++ b/tests_old/models/Role.php
@@ -1,5 +1,5 @@
 hasColumn('id', 'integer', null, array('primary', 'sequence'));
diff --git a/tests_old/models/SerializeTest.php b/tests_old/models/SerializeTest.php
index 9401e9d93..b3e02e8f6 100644
--- a/tests_old/models/SerializeTest.php
+++ b/tests_old/models/SerializeTest.php
@@ -1,5 +1,5 @@
 setColumn('tag', 'string', 100);
         $class->hasMany('Photo', array('local' => 'tag_id', 'foreign' => 'photo_id', 'refClass' => 'Phototag'));
diff --git a/tests_old/models/Task.php b/tests_old/models/Task.php
index e4359d94f..4dca90130 100644
--- a/tests_old/models/Task.php
+++ b/tests_old/models/Task.php
@@ -1,5 +1,5 @@
 setColumn('name', 'string',100); 
       $class->setColumn('parent_id', 'integer');
diff --git a/tests_old/models/TestMovie.php b/tests_old/models/TestMovie.php
index bf7c8b252..2e80d671c 100644
--- a/tests_old/models/TestMovie.php
+++ b/tests_old/models/TestMovie.php
@@ -1,5 +1,5 @@
 setColumn('vote', 'string', 30);
diff --git a/tests_old/models/TestRecord.php b/tests_old/models/TestRecord.php
index 2c9221ea3..3ebb48a82 100644
--- a/tests_old/models/TestRecord.php
+++ b/tests_old/models/TestRecord.php
@@ -1,5 +1,5 @@
 setColumn('mymixed', 'string', 100);
         $class->setColumn('mystring', 'string', 100,
diff --git a/tests_old/models/ValidatorTest_AddressModel.php b/tests_old/models/ValidatorTest_AddressModel.php
index 43608c974..08acd4d8b 100644
--- a/tests_old/models/ValidatorTest_AddressModel.php
+++ b/tests_old/models/ValidatorTest_AddressModel.php
@@ -1,5 +1,5 @@
 setColumn("id", "integer", 11, array('autoincrement' => true,
 													'primary'       => true
diff --git a/tests_old/models/ValidatorTest_ClientModel.php b/tests_old/models/ValidatorTest_ClientModel.php
index f5d06c526..dcc61798c 100644
--- a/tests_old/models/ValidatorTest_ClientModel.php
+++ b/tests_old/models/ValidatorTest_ClientModel.php
@@ -1,5 +1,5 @@
 setColumn('id', 'integer', 4, array('notnull' => true,
 	                                           'primary' => true,
diff --git a/tests_old/models/ValidatorTest_ClientToAddressModel.php b/tests_old/models/ValidatorTest_ClientToAddressModel.php
index 00a973d21..4676335cb 100644
--- a/tests_old/models/ValidatorTest_ClientToAddressModel.php
+++ b/tests_old/models/ValidatorTest_ClientToAddressModel.php
@@ -1,5 +1,5 @@
 setColumn("client_id", "integer", 11, array('primary' => true));
diff --git a/tests_old/models/ValidatorTest_DateModel.php b/tests_old/models/ValidatorTest_DateModel.php
index 4d7503bbf..4adcd3a33 100644
--- a/tests_old/models/ValidatorTest_DateModel.php
+++ b/tests_old/models/ValidatorTest_DateModel.php
@@ -1,5 +1,5 @@
 setColumn('birthday', 'date', null,
                 array('validators' => array('past')));
diff --git a/tests_old/models/ValidatorTest_FootballPlayer.php b/tests_old/models/ValidatorTest_FootballPlayer.php
index 7c53edb3d..819b885fb 100644
--- a/tests_old/models/ValidatorTest_FootballPlayer.php
+++ b/tests_old/models/ValidatorTest_FootballPlayer.php
@@ -1,5 +1,5 @@
 setColumn('person_id', 'string', 255);     
       $class->setColumn('team_name', 'string', 255);
diff --git a/tests_old/models/ValidatorTest_Person.php b/tests_old/models/ValidatorTest_Person.php
index 1a8072b03..5991beb51 100644
--- a/tests_old/models/ValidatorTest_Person.php
+++ b/tests_old/models/ValidatorTest_Person.php
@@ -1,5 +1,5 @@
 setColumn('identifier', 'integer', 4,
             array('validators' => array('notblank', 'unique')));
diff --git a/tests_old/models/VersioningTest.php b/tests_old/models/VersioningTest.php
index 83d349c14..66fd9610d 100644
--- a/tests_old/models/VersioningTest.php
+++ b/tests_old/models/VersioningTest.php
@@ -1,5 +1,5 @@
 hasMany('mmrUser_B', array('local' => 'group_id',
diff --git a/tests_old/models/mmrGroup_C.php b/tests_old/models/mmrGroup_C.php
index e62650e4d..04852d9e6 100644
--- a/tests_old/models/mmrGroup_C.php
+++ b/tests_old/models/mmrGroup_C.php
@@ -1,5 +1,5 @@