1
0
mirror of synced 2024-12-13 06:46:03 +03:00

[2.0] Changed identifier quoting strategy to something simpler. Dropped Doctrine prefix from annotations.

This commit is contained in:
romanb 2009-05-29 10:23:13 +00:00
parent f994680d54
commit f3677a5714
27 changed files with 304 additions and 258 deletions

View File

@ -97,6 +97,21 @@ class EventManager
} }
} }
/**
* Removes an event listener from the specified events.
*
* @param string|array $events
* @param object $listener
*/
public function removeEventListener($events, $listener)
{
foreach ((array)$events as $event) {
if ($key = array_search($listener, $this->_listeners[$event], true)) {
unset($this->_listeners[$event][$key]);
}
}
}
/** /**
* Adds an EventSubscriber. The subscriber is asked for all the events he is * Adds an EventSubscriber. The subscriber is asked for all the events he is
* interested in and added as a listener for these events. * interested in and added as a listener for these events.

View File

@ -47,7 +47,7 @@ class Configuration
public function __construct() public function __construct()
{ {
$this->_attributes = array( $this->_attributes = array(
'quoteIdentifiers' => false, //'quoteIdentifiers' => false,
'sqlLogger' => null 'sqlLogger' => null
); );
} }
@ -71,7 +71,7 @@ class Configuration
{ {
return $this->_attributes['sqlLogger']; return $this->_attributes['sqlLogger'];
} }
/*
public function getQuoteIdentifiers() public function getQuoteIdentifiers()
{ {
return $this->_attributes['quoteIdentifiers']; return $this->_attributes['quoteIdentifiers'];
@ -81,7 +81,7 @@ class Configuration
{ {
$this->_attributes['quoteIdentifiers'] = (bool) $bool; $this->_attributes['quoteIdentifiers'] = (bool) $bool;
} }
*/
public function setCustomTypes(array $types) public function setCustomTypes(array $types)
{ {
foreach ($types as $name => $typeClassName) { foreach ($types as $name => $typeClassName) {

View File

@ -150,13 +150,6 @@ class Connection
*/ */
protected $_driver; protected $_driver;
/**
* Whether to quote identifiers. Read from the configuration upon construction.
*
* @var boolean
*/
protected $_quoteIdentifiers = false;
/** /**
* Initializes a new instance of the Connection class. * Initializes a new instance of the Connection class.
* *
@ -188,8 +181,6 @@ class Connection
$this->_eventManager = $eventManager; $this->_eventManager = $eventManager;
$this->_platform = $driver->getDatabasePlatform(); $this->_platform = $driver->getDatabasePlatform();
$this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel(); $this->_transactionIsolationLevel = $this->_platform->getDefaultTransactionIsolationLevel();
$this->_quoteIdentifiers = $config->getQuoteIdentifiers();
$this->_platform->setQuoteIdentifiers($this->_quoteIdentifiers);
} }
/** /**
@ -482,10 +473,7 @@ class Connection
*/ */
public function quoteIdentifier($str) public function quoteIdentifier($str)
{ {
if ($this->_quoteIdentifiers) { return $this->_platform->quoteIdentifier($str);
return $this->_platform->quoteIdentifier($str);
}
return $str;
} }
/** /**

View File

@ -36,31 +36,11 @@ use Doctrine\DBAL\Types;
*/ */
abstract class AbstractPlatform abstract class AbstractPlatform
{ {
private $_quoteIdentifiers = false;
/** /**
* Constructor. * Constructor.
*/ */
public function __construct() {} public function __construct() {}
/**
* Sets whether to quote identifiers.
*/
public function setQuoteIdentifiers($bool)
{
$this->_quoteIdentifiers = $bool;
}
/**
* Gets whether the platform instance currently quotes identifiers in generated SQL.
*
* @return boolean TRUE
*/
public function getQuoteIdentifiers()
{
return $this->_quoteIdentifiers;
}
/** /**
* Gets the character used for identifier quoting. * Gets the character used for identifier quoting.
* *
@ -697,22 +677,12 @@ abstract class AbstractPlatform
*/ */
public function quoteIdentifier($str) public function quoteIdentifier($str)
{ {
if ( ! $this->_quoteIdentifiers) { if ($str[0] != '`') {
return $str; return $str;
} }
// quick fix for the identifiers that contain a dot
if (strpos($str, '.')) {
$e = explode('.', $str);
return $this->quoteIdentifier($e[0])
. '.'
. $this->quoteIdentifier($e[1]);
}
$c = $this->getIdentifierQuoteCharacter(); $c = $this->getIdentifierQuoteCharacter();
$str = str_replace($c, $c . $c, $str);
return $c . $str . $c; return $c . trim($str, '`') . $c;
} }
/** /**

View File

@ -35,7 +35,7 @@ require __DIR__ . '/DoctrineAnnotations.php';
* The AnnotationDriver reads the mapping metadata from docblock annotations * The AnnotationDriver reads the mapping metadata from docblock annotations
* with the help of the Addendum reflection extensions. * with the help of the Addendum reflection extensions.
* *
* @author robo * @author Roman Borschel <roman@code-factory.org>
* @since 2.0 * @since 2.0
*/ */
class AnnotationDriver class AnnotationDriver
@ -48,27 +48,26 @@ class AnnotationDriver
$annotClass = new \ReflectionAnnotatedClass($className); $annotClass = new \ReflectionAnnotatedClass($className);
// Evaluate DoctrineEntity annotation // Evaluate DoctrineEntity annotation
if (($entityAnnot = $annotClass->getAnnotation('DoctrineEntity')) === false) { if (($entityAnnot = $annotClass->getAnnotation('Entity')) === false) {
throw DoctrineException::updateMe("$className is no entity."); throw DoctrineException::updateMe("$className is no entity.");
} }
$metadata->setCustomRepositoryClass($entityAnnot->repositoryClass); $metadata->setCustomRepositoryClass($entityAnnot->repositoryClass);
// Evaluate DoctrineTable annotation // Evaluate DoctrineTable annotation
if ($tableAnnot = $annotClass->getAnnotation('DoctrineTable')) { if ($tableAnnot = $annotClass->getAnnotation('Table')) {
$metadata->setPrimaryTable(array( $metadata->setPrimaryTable(array(
'name' => $tableAnnot->name, 'name' => $tableAnnot->name,
'schema' => $tableAnnot->schema, 'schema' => $tableAnnot->schema
'catalog' => $tableAnnot->catalog
)); ));
} }
// Evaluate DoctrineInheritanceType annotation // Evaluate DoctrineInheritanceType annotation
if ($inheritanceTypeAnnot = $annotClass->getAnnotation('DoctrineInheritanceType')) { if ($inheritanceTypeAnnot = $annotClass->getAnnotation('InheritanceType')) {
$metadata->setInheritanceType($inheritanceTypeAnnot->value); $metadata->setInheritanceType($inheritanceTypeAnnot->value);
} }
// Evaluate DoctrineDiscriminatorColumn annotation // Evaluate DoctrineDiscriminatorColumn annotation
if ($discrColumnAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorColumn')) { if ($discrColumnAnnot = $annotClass->getAnnotation('DiscriminatorColumn')) {
$metadata->setDiscriminatorColumn(array( $metadata->setDiscriminatorColumn(array(
'name' => $discrColumnAnnot->name, 'name' => $discrColumnAnnot->name,
'type' => $discrColumnAnnot->type, 'type' => $discrColumnAnnot->type,
@ -77,17 +76,17 @@ class AnnotationDriver
} }
// Evaluate DoctrineDiscriminatorMap annotation // Evaluate DoctrineDiscriminatorMap annotation
if ($discrValueAnnot = $annotClass->getAnnotation('DoctrineDiscriminatorValue')) { if ($discrValueAnnot = $annotClass->getAnnotation('DiscriminatorValue')) {
$metadata->setDiscriminatorValue($discrValueAnnot->value); $metadata->setDiscriminatorValue($discrValueAnnot->value);
} }
// Evaluate DoctrineSubClasses annotation // Evaluate DoctrineSubClasses annotation
if ($subClassesAnnot = $annotClass->getAnnotation('DoctrineSubClasses')) { if ($subClassesAnnot = $annotClass->getAnnotation('SubClasses')) {
$metadata->setSubclasses($subClassesAnnot->value); $metadata->setSubclasses($subClassesAnnot->value);
} }
// Evaluate DoctrineChangeTrackingPolicy annotation // Evaluate DoctrineChangeTrackingPolicy annotation
if ($changeTrackingAnnot = $annotClass->getAnnotation('DoctrineChangeTrackingPolicy')) { if ($changeTrackingAnnot = $annotClass->getAnnotation('ChangeTrackingPolicy')) {
$metadata->setChangeTrackingPolicy($changeTrackingAnnot->value); $metadata->setChangeTrackingPolicy($changeTrackingAnnot->value);
} }
@ -102,7 +101,7 @@ class AnnotationDriver
// Check for DoctrineJoinColummn/DoctrineJoinColumns annotations // Check for DoctrineJoinColummn/DoctrineJoinColumns annotations
$joinColumns = array(); $joinColumns = array();
if ($joinColumnAnnot = $property->getAnnotation('DoctrineJoinColumn')) { if ($joinColumnAnnot = $property->getAnnotation('JoinColumn')) {
$joinColumns[] = array( $joinColumns[] = array(
'name' => $joinColumnAnnot->name, 'name' => $joinColumnAnnot->name,
'referencedColumnName' => $joinColumnAnnot->referencedColumnName, 'referencedColumnName' => $joinColumnAnnot->referencedColumnName,
@ -111,61 +110,63 @@ class AnnotationDriver
'onDelete' => $joinColumnAnnot->onDelete, 'onDelete' => $joinColumnAnnot->onDelete,
'onUpdate' => $joinColumnAnnot->onUpdate 'onUpdate' => $joinColumnAnnot->onUpdate
); );
} else if ($joinColumnsAnnot = $property->getAnnotation('DoctrineJoinColumns')) { } else if ($joinColumnsAnnot = $property->getAnnotation('JoinColumns')) {
$joinColumns = $joinColumnsAnnot->value; $joinColumns = $joinColumnsAnnot->value;
} }
// Field can only be annotated with one of: DoctrineColumn, // Field can only be annotated with one of: DoctrineColumn,
// DoctrineOneToOne, DoctrineOneToMany, DoctrineManyToOne, DoctrineManyToMany // DoctrineOneToOne, DoctrineOneToMany, DoctrineManyToOne, DoctrineManyToMany
if ($columnAnnot = $property->getAnnotation('DoctrineColumn')) { if ($columnAnnot = $property->getAnnotation('Column')) {
if ($columnAnnot->type == null) { if ($columnAnnot->type == null) {
throw DoctrineException::updateMe("Missing type on property " . $property->getName()); throw DoctrineException::updateMe("Missing type on property " . $property->getName());
} }
$mapping['type'] = $columnAnnot->type; $mapping['type'] = $columnAnnot->type;
$mapping['length'] = $columnAnnot->length; $mapping['length'] = $columnAnnot->length;
$mapping['nullable'] = $columnAnnot->nullable; $mapping['nullable'] = $columnAnnot->nullable;
if ($idAnnot = $property->getAnnotation('DoctrineId')) { if (isset($columnAnnot->name)) {
$mapping['columnName'] = $columnAnnot->name;
}
if ($idAnnot = $property->getAnnotation('Id')) {
$mapping['id'] = true; $mapping['id'] = true;
} }
if ($generatedValueAnnot = $property->getAnnotation('DoctrineGeneratedValue')) { if ($generatedValueAnnot = $property->getAnnotation('GeneratedValue')) {
$metadata->setIdGeneratorType($generatedValueAnnot->strategy); $metadata->setIdGeneratorType($generatedValueAnnot->strategy);
} }
$metadata->mapField($mapping); $metadata->mapField($mapping);
// Check for SequenceGenerator/TableGenerator definition // Check for SequenceGenerator/TableGenerator definition
if ($seqGeneratorAnnot = $property->getAnnotation('DoctrineSequenceGenerator')) { if ($seqGeneratorAnnot = $property->getAnnotation('SequenceGenerator')) {
$metadata->setSequenceGeneratorDefinition(array( $metadata->setSequenceGeneratorDefinition(array(
'sequenceName' => $seqGeneratorAnnot->sequenceName, 'sequenceName' => $seqGeneratorAnnot->sequenceName,
'allocationSize' => $seqGeneratorAnnot->allocationSize, 'allocationSize' => $seqGeneratorAnnot->allocationSize,
'initialValue' => $seqGeneratorAnnot->initialValue 'initialValue' => $seqGeneratorAnnot->initialValue
)); ));
} else if ($tblGeneratorAnnot = $property->getAnnotation('DoctrineTableGenerator')) { } else if ($tblGeneratorAnnot = $property->getAnnotation('TableGenerator')) {
throw new DoctrineException("DoctrineTableGenerator not yet implemented."); throw new DoctrineException("DoctrineTableGenerator not yet implemented.");
} }
} else if ($oneToOneAnnot = $property->getAnnotation('DoctrineOneToOne')) { } else if ($oneToOneAnnot = $property->getAnnotation('OneToOne')) {
$mapping['targetEntity'] = $oneToOneAnnot->targetEntity; $mapping['targetEntity'] = $oneToOneAnnot->targetEntity;
$mapping['joinColumns'] = $joinColumns; $mapping['joinColumns'] = $joinColumns;
$mapping['mappedBy'] = $oneToOneAnnot->mappedBy; $mapping['mappedBy'] = $oneToOneAnnot->mappedBy;
$mapping['cascade'] = $oneToOneAnnot->cascade; $mapping['cascade'] = $oneToOneAnnot->cascade;
$metadata->mapOneToOne($mapping); $metadata->mapOneToOne($mapping);
} else if ($oneToManyAnnot = $property->getAnnotation('DoctrineOneToMany')) { } else if ($oneToManyAnnot = $property->getAnnotation('OneToMany')) {
$mapping['mappedBy'] = $oneToManyAnnot->mappedBy; $mapping['mappedBy'] = $oneToManyAnnot->mappedBy;
$mapping['targetEntity'] = $oneToManyAnnot->targetEntity; $mapping['targetEntity'] = $oneToManyAnnot->targetEntity;
$mapping['cascade'] = $oneToManyAnnot->cascade; $mapping['cascade'] = $oneToManyAnnot->cascade;
$metadata->mapOneToMany($mapping); $metadata->mapOneToMany($mapping);
} else if ($manyToOneAnnot = $property->getAnnotation('DoctrineManyToOne')) { } else if ($manyToOneAnnot = $property->getAnnotation('ManyToOne')) {
$mapping['joinColumns'] = $joinColumns; $mapping['joinColumns'] = $joinColumns;
$mapping['cascade'] = $manyToOneAnnot->cascade; $mapping['cascade'] = $manyToOneAnnot->cascade;
$mapping['targetEntity'] = $manyToOneAnnot->targetEntity; $mapping['targetEntity'] = $manyToOneAnnot->targetEntity;
$metadata->mapManyToOne($mapping); $metadata->mapManyToOne($mapping);
} else if ($manyToManyAnnot = $property->getAnnotation('DoctrineManyToMany')) { } else if ($manyToManyAnnot = $property->getAnnotation('ManyToMany')) {
$joinTable = array(); $joinTable = array();
if ($joinTableAnnot = $property->getAnnotation('DoctrineJoinTable')) { if ($joinTableAnnot = $property->getAnnotation('JoinTable')) {
$joinTable = array( $joinTable = array(
'name' => $joinTableAnnot->name, 'name' => $joinTableAnnot->name,
'schema' => $joinTableAnnot->schema, 'schema' => $joinTableAnnot->schema,
'catalog' => $joinTableAnnot->catalog,
'joinColumns' => $joinTableAnnot->joinColumns, 'joinColumns' => $joinTableAnnot->joinColumns,
'inverseJoinColumns' => $joinTableAnnot->inverseJoinColumns 'inverseJoinColumns' => $joinTableAnnot->inverseJoinColumns
); );
@ -182,8 +183,8 @@ class AnnotationDriver
/** /**
* Whether the class with the specified name should have its metadata loaded. * Whether the class with the specified name should have its metadata loaded.
* This is only the case if it is annotated with either @DoctrineEntity or * This is only the case if it is annotated with either @Entity or
* @DoctrineMappedSuperclass in the class doc block. * @MappedSuperclass in the class doc block.
* *
* @param string $className * @param string $className
* @return boolean * @return boolean
@ -192,7 +193,7 @@ class AnnotationDriver
{ {
$refClass = new \ReflectionClass($className); $refClass = new \ReflectionClass($className);
$docComment = $refClass->getDocComment(); $docComment = $refClass->getDocComment();
return strpos($docComment, '@DoctrineEntity') === false && return strpos($docComment, '@Entity') === false &&
strpos($docComment, '@DoctrineMappedSuperclass') === false; strpos($docComment, '@MappedSuperclass') === false;
} }
} }

View File

@ -21,25 +21,25 @@
/* Annotations */ /* Annotations */
final class DoctrineEntity extends \Annotation { final class Entity extends \Annotation {
public $repositoryClass; public $repositoryClass;
} }
final class DoctrineInheritanceType extends \Annotation {} final class InheritanceType extends \Annotation {}
final class DoctrineDiscriminatorColumn extends \Annotation { final class DiscriminatorColumn extends \Annotation {
public $name; public $name;
public $type; public $type;
public $length; public $length;
} }
final class DoctrineDiscriminatorMap extends \Annotation {} //final class DiscriminatorMap extends \Annotation {}
final class DoctrineDiscriminatorValue extends \Annotation {} final class DiscriminatorValue extends \Annotation {}
final class DoctrineSubClasses extends \Annotation {} final class SubClasses extends \Annotation {}
final class DoctrineId extends \Annotation {} final class Id extends \Annotation {}
final class DoctrineGeneratedValue extends \Annotation { final class GeneratedValue extends \Annotation {
public $strategy; public $strategy;
//public $generator; //public $generator;
} }
final class DoctrineVersion extends \Annotation {} final class Version extends \Annotation {}
final class DoctrineJoinColumn extends \Annotation { final class JoinColumn extends \Annotation {
public $name; public $name;
public $referencedColumnName; public $referencedColumnName;
public $unique = false; public $unique = false;
@ -47,60 +47,57 @@ final class DoctrineJoinColumn extends \Annotation {
public $onDelete; public $onDelete;
public $onUpdate; public $onUpdate;
} }
final class DoctrineJoinColumns extends \Annotation {} final class JoinColumns extends \Annotation {}
final class DoctrineColumn extends \Annotation { final class Column extends \Annotation {
public $type; public $type;
public $length; public $length;
public $unique = false; public $unique = false;
public $nullable = false; public $nullable = false;
public $quote = false; public $name;
//public $quote = false;
} }
final class DoctrineOneToOne extends \Annotation { final class OneToOne extends \Annotation {
public $targetEntity; public $targetEntity;
public $mappedBy; public $mappedBy;
public $cascade; public $cascade;
public $fetch; public $fetch;
public $optional; public $optional;
} }
final class DoctrineOneToMany extends \Annotation { final class OneToMany extends \Annotation {
public $mappedBy; public $mappedBy;
public $targetEntity; public $targetEntity;
public $cascade; public $cascade;
public $fetch; public $fetch;
} }
final class DoctrineManyToOne extends \Annotation { final class ManyToOne extends \Annotation {
public $targetEntity; public $targetEntity;
public $cascade; public $cascade;
public $fetch; public $fetch;
public $optional; public $optional;
} }
final class DoctrineManyToMany extends \Annotation { final class ManyToMany extends \Annotation {
public $targetEntity; public $targetEntity;
public $mappedBy; public $mappedBy;
public $cascade; public $cascade;
public $fetch; public $fetch;
} }
final class DoctrineElementCollection extends \Annotation { final class ElementCollection extends \Annotation {
public $tableName; public $tableName;
} }
final class DoctrineTable extends \Annotation { final class Table extends \Annotation {
public $name; public $name;
public $catalog;
public $schema; public $schema;
} }
final class DoctrineJoinTable extends \Annotation { final class JoinTable extends \Annotation {
public $name; public $name;
public $catalog;
public $schema; public $schema;
public $joinColumns; public $joinColumns;
public $inverseJoinColumns; public $inverseJoinColumns;
} }
final class DoctrineSequenceGenerator extends \Annotation { final class SequenceGenerator extends \Annotation {
//public $name; //public $name;
public $sequenceName; public $sequenceName;
public $allocationSize = 20; public $allocationSize = 10;
public $initialValue = 1; public $initialValue = 1;
/** The name of the class that defines the generator. */
//public $definingClass;
} }
final class DoctrineChangeTrackingPolicy extends \Annotation {} final class ChangeTrackingPolicy extends \Annotation {}

View File

@ -26,6 +26,7 @@ use Doctrine\ORM\EntityManager;
use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\PersistentCollection; use Doctrine\ORM\PersistentCollection;
use Doctrine\ORM\Mapping\ClassMetadata; use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Events;
/** /**
* Base class for all EntityPersisters. * Base class for all EntityPersisters.
@ -66,6 +67,13 @@ class StandardEntityPersister
*/ */
protected $_em; protected $_em;
/**
* The EventManager instance.
*
* @var Doctrine\Common\EventManager
*/
protected $_evm;
/** /**
* Queued inserts. * Queued inserts.
* *
@ -81,6 +89,7 @@ class StandardEntityPersister
public function __construct(EntityManager $em, ClassMetadata $class) public function __construct(EntityManager $em, ClassMetadata $class)
{ {
$this->_em = $em; $this->_em = $em;
$this->_evm = $em->getEventManager();
$this->_entityName = $class->name; $this->_entityName = $class->name;
$this->_conn = $em->getConnection(); $this->_conn = $em->getConnection();
$this->_class = $class; $this->_class = $class;
@ -113,12 +122,19 @@ class StandardEntityPersister
$stmt = $this->_conn->prepare($this->_class->insertSql); $stmt = $this->_conn->prepare($this->_class->insertSql);
$primaryTableName = $this->_class->primaryTable['name']; $primaryTableName = $this->_class->primaryTable['name'];
$sqlLogger = $this->_conn->getConfiguration()->getSqlLogger(); $sqlLogger = $this->_conn->getConfiguration()->getSqlLogger();
$hasPreInsertListeners = $this->_evm->hasListeners(Events::preInsert);
$hasPostInsertListeners = $this->_evm->hasListeners(Events::postInsert);
foreach ($this->_queuedInserts as $entity) { foreach ($this->_queuedInserts as $entity) {
$insertData = array(); $insertData = array();
$this->_prepareData($entity, $insertData, true); $this->_prepareData($entity, $insertData, true);
if ($hasPreInsertListeners) {
$this->_preInsert($entity);
}
$paramIndex = 1; $paramIndex = 1;
if ($sqlLogger) { if ($sqlLogger) {
//TODO: Log type //TODO: Log type
@ -139,6 +155,10 @@ class StandardEntityPersister
if ($isPostInsertId) { if ($isPostInsertId) {
$postInsertIds[$idGen->generate($this->_em, $entity)] = $entity; $postInsertIds[$idGen->generate($this->_em, $entity)] = $entity;
} }
if ($hasPostInsertListeners) {
$this->_postInsert($entity);
}
} }
$stmt->closeCursor(); $stmt->closeCursor();
@ -159,7 +179,16 @@ class StandardEntityPersister
$id = array_combine($this->_class->getIdentifierFieldNames(), $id = array_combine($this->_class->getIdentifierFieldNames(),
$this->_em->getUnitOfWork()->getEntityIdentifier($entity)); $this->_em->getUnitOfWork()->getEntityIdentifier($entity));
$tableName = $this->_class->primaryTable['name']; $tableName = $this->_class->primaryTable['name'];
if ($this->_evm->hasListeners(Events::preUpdate)) {
$this->_preUpdate($entity);
}
$this->_conn->update($tableName, $updateData[$tableName], $id); $this->_conn->update($tableName, $updateData[$tableName], $id);
if ($this->_evm->hasListeners(Events::postUpdate)) {
$this->_postUpdate($entity);
}
} }
/** /**
@ -282,8 +311,7 @@ class StandardEntityPersister
$result[$this->getOwningTable($field)][$columnName] = null; $result[$this->getOwningTable($field)][$columnName] = null;
} else { } else {
$result[$this->getOwningTable($field)][$columnName] = Type::getType( $result[$this->getOwningTable($field)][$columnName] = Type::getType(
$this->_class->fieldMappings[$field]['type']) $this->_class->fieldMappings[$field]['type'])->convertToDatabaseValue($newVal, $platform);
->convertToDatabaseValue($newVal, $platform);
} }
} }
} }
@ -382,4 +410,50 @@ class StandardEntityPersister
return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName() return 'SELECT ' . $columnList . ' FROM ' . $this->_class->getTableName()
. ' WHERE ' . $conditionSql; . ' WHERE ' . $conditionSql;
} }
/**
* Dispatches the preInsert event for the given entity.
*
* @param object $entity
*/
final protected function _preInsert($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreInsertEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preInsert, $eventArgs);
}
/**
* Dispatches the postInsert event for the given entity.
*
* @param object $entity
*/
final protected function _postInsert($entity)
{
$this->_evm->dispatchEvent(Events::postInsert);
}
/**
* Dispatches the preUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _preUpdate($entity)
{
$eventArgs = new \Doctrine\ORM\Event\PreUpdateEventArgs(
$entity, $this->_em->getUnitOfWork()->getEntityChangeSet($entity)
);
$this->_evm->dispatchEvent(Events::preUpdate, $eventArgs);
}
/**
* Dispatches the postUpdate event for the given entity.
*
* @param object $entity
*/
final protected function _postUpdate($entity)
{
$this->_evm->dispatchEvent(Events::postUpdate);
}
} }

View File

@ -42,6 +42,7 @@ class SqlWalker
private $_scalarResultCounter = 0; private $_scalarResultCounter = 0;
private $_parserResult; private $_parserResult;
private $_em; private $_em;
private $_conn;
private $_query; private $_query;
private $_dqlToSqlAliasMap = array(); private $_dqlToSqlAliasMap = array();
/** Map of all components/classes that appear in the DQL query. */ /** Map of all components/classes that appear in the DQL query. */
@ -67,6 +68,7 @@ class SqlWalker
$this->_resultSetMapping = $parserResult->getResultSetMapping(); $this->_resultSetMapping = $parserResult->getResultSetMapping();
$this->_query = $query; $this->_query = $query;
$this->_em = $query->getEntityManager(); $this->_em = $query->getEntityManager();
$this->_conn = $this->_em->getConnection();
$this->_parserResult = $parserResult; $this->_parserResult = $parserResult;
$this->_queryComponents = $queryComponents; $this->_queryComponents = $queryComponents;
} }
@ -405,7 +407,7 @@ class SqlWalker
if ($beginning) $beginning = false; else $sql .= ', '; if ($beginning) $beginning = false; else $sql .= ', ';
$sqlTableAlias = $this->getSqlTableAlias($tableName . $dqlAlias); $sqlTableAlias = $this->getSqlTableAlias($tableName . $dqlAlias);
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']); $columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias; $sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName); $this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
} }
@ -419,7 +421,7 @@ class SqlWalker
if ($beginning) $beginning = false; else $sql .= ', '; if ($beginning) $beginning = false; else $sql .= ', ';
$sqlTableAlias = $this->getSqlTableAlias($subClass->primaryTable['name'] . $dqlAlias); $sqlTableAlias = $this->getSqlTableAlias($subClass->primaryTable['name'] . $dqlAlias);
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']); $columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias; $sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName); $this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
} }
} }
@ -435,7 +437,7 @@ class SqlWalker
foreach ($fieldMappings as $fieldName => $mapping) { foreach ($fieldMappings as $fieldName => $mapping) {
if ($beginning) $beginning = false; else $sql .= ', '; if ($beginning) $beginning = false; else $sql .= ', ';
$columnAlias = $this->getSqlColumnAlias($mapping['columnName']); $columnAlias = $this->getSqlColumnAlias($mapping['columnName']);
$sql .= $sqlTableAlias . '.' . $mapping['columnName'] . ' AS ' . $columnAlias; $sql .= $sqlTableAlias . '.' . $this->_conn->quoteIdentifier($mapping['columnName']) . ' AS ' . $columnAlias;
$this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName); $this->_resultSetMapping->addFieldResult($dqlAlias, $columnAlias, $fieldName);
} }
} }
@ -1100,7 +1102,7 @@ class SqlWalker
public function getSqlColumnAlias($columnName) public function getSqlColumnAlias($columnName)
{ {
return $columnName . $this->_aliasCounter++; return trim($columnName, '`') . $this->_aliasCounter++;
} }
/** /**

View File

@ -6,36 +6,36 @@ namespace Doctrine\Tests\Models\CMS;
* CmsAddress * CmsAddress
* *
* @author Roman S. Borschel * @author Roman S. Borschel
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_addresses") * @Table(name="cms_addresses")
*/ */
class CmsAddress class CmsAddress
{ {
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineId * @Id
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $country; public $country;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $zip; public $zip;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $city; public $city;
/** /**
* @DoctrineOneToOne(targetEntity="CmsUser") * @OneToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id") * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;

View File

@ -3,32 +3,32 @@
namespace Doctrine\Tests\Models\CMS; namespace Doctrine\Tests\Models\CMS;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_articles") * @Table(name="cms_articles")
*/ */
class CmsArticle class CmsArticle
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
public $topic; public $topic;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
public $text; public $text;
/** /**
* @DoctrineManyToOne(targetEntity="CmsUser") * @ManyToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id") * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;
/** /**
* @DoctrineOneToMany(targetEntity="CmsComment", mappedBy="article") * @OneToMany(targetEntity="CmsComment", mappedBy="article")
*/ */
public $comments; public $comments;
} }

View File

@ -3,28 +3,28 @@
namespace Doctrine\Tests\Models\CMS; namespace Doctrine\Tests\Models\CMS;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_comments") * @Table(name="cms_comments")
*/ */
class CmsComment class CmsComment
{ {
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineId * @Id
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
public $topic; public $topic;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
public $text; public $text;
/** /**
* @DoctrineManyToOne(targetEntity="CmsArticle") * @ManyToOne(targetEntity="CmsArticle")
* @DoctrineJoinColumn(name="article_id", referencedColumnName="id") * @JoinColumn(name="article_id", referencedColumnName="id")
*/ */
public $article; public $article;
} }

View File

@ -6,26 +6,26 @@ namespace Doctrine\Tests\Models\CMS;
* Description of CmsEmployee * Description of CmsEmployee
* *
* @author robo * @author robo
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_employees") * @Table(name="cms_employees")
*/ */
class CmsEmployee class CmsEmployee
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
private $name; private $name;
/** /**
* @DoctrineOneToOne(targetEntity="CmsEmployee") * @OneToOne(targetEntity="CmsEmployee")
* @DoctrineJoinColumn(name="spouse_id", referencedColumnName="id") * @JoinColumn(name="spouse_id", referencedColumnName="id")
*/ */
private $spouse; private $spouse;

View File

@ -10,23 +10,23 @@ namespace Doctrine\Tests\Models\CMS;
* Description of CmsGroup * Description of CmsGroup
* *
* @author robo * @author robo
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_groups") * @Table(name="cms_groups")
*/ */
class CmsGroup class CmsGroup
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $name; public $name;
/** /**
* @DoctrineManyToMany(targetEntity="CmsUser", mappedBy="groups") * @ManyToMany(targetEntity="CmsUser", mappedBy="groups")
*/ */
public $users; public $users;

View File

@ -3,19 +3,19 @@
namespace Doctrine\Tests\Models\CMS; namespace Doctrine\Tests\Models\CMS;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_phonenumbers") * @Table(name="cms_phonenumbers")
*/ */
class CmsPhonenumber class CmsPhonenumber
{ {
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
* @DoctrineId * @Id
*/ */
public $phonenumber; public $phonenumber;
/** /**
* @DoctrineManyToOne(targetEntity="CmsUser") * @ManyToOne(targetEntity="CmsUser")
* @DoctrineJoinColumn(name="user_id", referencedColumnName="id") * @JoinColumn(name="user_id", referencedColumnName="id")
*/ */
public $user; public $user;

View File

@ -3,44 +3,43 @@
namespace Doctrine\Tests\Models\CMS; namespace Doctrine\Tests\Models\CMS;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="cms_users") * @Table(name="cms_users")
*/ */
class CmsUser class CmsUser
{ {
/** /**
* @DoctrineId * @Id @Column(type="integer")
* @DoctrineColumn(type="integer") * @GeneratedValue(strategy="auto")
* @DoctrineGeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $status; public $status;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
public $username; public $username;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
public $name; public $name;
/** /**
* @DoctrineOneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save", "delete"}) * @OneToMany(targetEntity="CmsPhonenumber", mappedBy="user", cascade={"save", "delete"})
*/ */
public $phonenumbers; public $phonenumbers;
/** /**
* @DoctrineOneToMany(targetEntity="CmsArticle", mappedBy="user") * @OneToMany(targetEntity="CmsArticle", mappedBy="user")
*/ */
public $articles; public $articles;
/** /**
* @DoctrineOneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"save"}) * @OneToOne(targetEntity="CmsAddress", mappedBy="user", cascade={"save"})
*/ */
public $address; public $address;
/** /**
* @DoctrineManyToMany(targetEntity="CmsGroup", cascade={"save"}) * @ManyToMany(targetEntity="CmsGroup", cascade={"save"})
* @DoctrineJoinTable(name="cms_users_groups", * @JoinTable(name="cms_users_groups",
joinColumns={{"name"="user_id", "referencedColumnName"="id"}}, joinColumns={{"name"="user_id", "referencedColumnName"="id"}},
inverseJoinColumns={{"name"="group_id", "referencedColumnName"="id"}}) inverseJoinColumns={{"name"="group_id", "referencedColumnName"="id"}})
*/ */

View File

@ -3,20 +3,20 @@
namespace Doctrine\Tests\Models\Company; namespace Doctrine\Tests\Models\Company;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="company_employees") * @Table(name="company_employees")
* @DoctrineDiscriminatorValue("employee") * @DiscriminatorValue("employee")
* @DoctrineSubClasses({"Doctrine\Tests\Models\Company\CompanyManager"}) * @SubClasses({"Doctrine\Tests\Models\Company\CompanyManager"})
*/ */
class CompanyEmployee extends CompanyPerson class CompanyEmployee extends CompanyPerson
{ {
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
*/ */
private $salary; private $salary;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
private $department; private $department;

View File

@ -3,14 +3,14 @@
namespace Doctrine\Tests\Models\Company; namespace Doctrine\Tests\Models\Company;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="company_managers") * @Table(name="company_managers")
* @DoctrineDiscriminatorValue("manager") * @DiscriminatorValue("manager")
*/ */
class CompanyManager extends CompanyEmployee class CompanyManager extends CompanyEmployee
{ {
/** /**
* @DoctrineColumn(type="string", length="250") * @Column(type="string", length="250")
*/ */
private $title; private $title;

View File

@ -6,29 +6,29 @@ namespace Doctrine\Tests\Models\Company;
* Description of CompanyPerson * Description of CompanyPerson
* *
* @author robo * @author robo
* @DoctrineEntity * @Entity
* @DoctrineTable(name="company_persons") * @Table(name="company_persons")
* @DoctrineDiscriminatorValue("person") * @DiscriminatorValue("person")
* @DoctrineInheritanceType("joined") * @InheritanceType("joined")
* @DoctrineDiscriminatorColumn(name="discr", type="string") * @DiscriminatorColumn(name="discr", type="string")
* @DoctrineSubClasses({"Doctrine\Tests\Models\Company\CompanyEmployee", * @SubClasses({"Doctrine\Tests\Models\Company\CompanyEmployee",
"Doctrine\Tests\Models\Company\CompanyManager"}) "Doctrine\Tests\Models\Company\CompanyManager"})
*/ */
class CompanyPerson class CompanyPerson
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
private $name; private $name;
/** /**
* @DoctrineOneToOne(targetEntity="CompanyPerson") * @OneToOne(targetEntity="CompanyPerson")
* @DoctrineJoinColumn(name="spouse_id", referencedColumnName="id") * @JoinColumn(name="spouse_id", referencedColumnName="id")
*/ */
private $spouse; private $spouse;

View File

@ -3,12 +3,12 @@
namespace Doctrine\Tests\Models\Forum; namespace Doctrine\Tests\Models\Forum;
/** /**
* @DoctrineEntity * @Entity
*/ */
class ForumAdministrator extends ForumUser class ForumAdministrator extends ForumUser
{ {
/** /**
* @DoctrineColumn(type="integer", name="access_level") * @Column(type="integer", name="access_level")
*/ */
public $accessLevel; public $accessLevel;
} }

View File

@ -3,15 +3,15 @@
namespace Doctrine\Tests\Models\Forum; namespace Doctrine\Tests\Models\Forum;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="forum_avatars") * @Table(name="forum_avatars")
*/ */
class ForumAvatar class ForumAvatar
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
} }

View File

@ -6,23 +6,23 @@ namespace Doctrine\Tests\Models\Forum;
* Represents a board in a forum. * Represents a board in a forum.
* *
* @author robo * @author robo
* @DoctrineEntity * @Entity
* @DoctrineTable(name="forum_boards") * @Table(name="forum_boards")
*/ */
class ForumBoard class ForumBoard
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
*/ */
public $position; public $position;
/** /**
* @DoctrineManyToOne(targetEntity="ForumCategory") * @ManyToOne(targetEntity="ForumCategory")
* @DoctrineJoinColumn(name="category_id", referencedColumnName="id") * @JoinColumn(name="category_id", referencedColumnName="id")
*/ */
public $category; public $category;
} }

View File

@ -3,26 +3,26 @@
namespace Doctrine\Tests\Models\Forum; namespace Doctrine\Tests\Models\Forum;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="forum_categories") * @Table(name="forum_categories")
*/ */
class ForumCategory class ForumCategory
{ {
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineId * @Id
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
*/ */
public $position; public $position;
/** /**
* @DoctrineColumn(type="string", length=255) * @Column(type="string", length=255)
*/ */
public $name; public $name;
/** /**
* @DoctrineOneToMany(targetEntity="ForumBoard", mappedBy="category") * @OneToMany(targetEntity="ForumBoard", mappedBy="category")
*/ */
public $boards; public $boards;

View File

@ -3,19 +3,19 @@
namespace Doctrine\Tests\Models\Forum; namespace Doctrine\Tests\Models\Forum;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="forum_entries") * @Table(name="forum_entries")
*/ */
class ForumEntry class ForumEntry
{ {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $topic; public $topic;
} }

View File

@ -3,24 +3,24 @@
namespace Doctrine\Tests\Models\Forum; namespace Doctrine\Tests\Models\Forum;
/** /**
* @DoctrineEntity * @Entity
* @DoctrineTable(name="forum_users") * @Table(name="forum_users")
*/ */
class ForumUser class ForumUser
{ {
/** /**
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineId * @Id
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
public $id; public $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
public $username; public $username;
/** /**
* @DoctrineOneToOne(targetEntity="ForumAvatar", cascade={"save"}) * @OneToOne(targetEntity="ForumAvatar", cascade={"save"})
* @DoctrineJoinColumn(name="avatar_id", referencedColumnName="id") * @JoinColumn(name="avatar_id", referencedColumnName="id")
*/ */
public $avatar; public $avatar;

View File

@ -18,12 +18,12 @@ class SequenceGeneratorTest extends \Doctrine\Tests\OrmFunctionalTestCase
} }
/** /**
* @DoctrineEntity * @Entity
*/ */
class SeqUser { class SeqUser {
/** /**
* @DoctrineId * @Id
* @DoctrineIdGenerator("sequence") * @IdGenerator("sequence")
*/ */
private $id; private $id;

View File

@ -98,22 +98,22 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase
} }
/** /**
* @DoctrineEntity * @Entity
* @DoctrineInheritanceType("singleTable") * @InheritanceType("singleTable")
* @DoctrineDiscriminatorColumn(name="discr", type="string") * @DiscriminatorColumn(name="discr", type="string")
* @DoctrineSubClasses({"Doctrine\Tests\ORM\Functional\ChildEntity"}) * @SubClasses({"Doctrine\Tests\ORM\Functional\ChildEntity"})
* @DoctrineDiscriminatorValue("parent") * @DiscriminatorValue("parent")
*/ */
class ParentEntity { class ParentEntity {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
private $data; private $data;
@ -131,17 +131,17 @@ class ParentEntity {
} }
/** /**
* @DoctrineEntity * @Entity
* @DoctrineDiscriminatorValue("child") * @DiscriminatorValue("child")
*/ */
class ChildEntity extends ParentEntity { class ChildEntity extends ParentEntity {
/** /**
* @DoctrineColumn(type="integer", nullable=true) * @Column(name="`number`", type="integer", nullable=true)
*/ */
private $number; private $number;
/** /**
* @DoctrineOneToOne(targetEntity="RelatedEntity") * @OneToOne(targetEntity="RelatedEntity")
* @DoctrineJoinColumn(name="related_entity_id", referencedColumnName="id") * @JoinColumn(name="related_entity_id", referencedColumnName="id")
*/ */
private $relatedEntity; private $relatedEntity;
@ -164,21 +164,21 @@ class ChildEntity extends ParentEntity {
} }
/** /**
* @DoctrineEntity * @Entity
*/ */
class RelatedEntity { class RelatedEntity {
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="string", length=50) * @Column(type="string", length=50)
*/ */
private $name; private $name;
/** /**
* @DoctrineOneToOne(targetEntity="ChildEntity", mappedBy="relatedEntity") * @OneToOne(targetEntity="ChildEntity", mappedBy="relatedEntity")
*/ */
private $owner; private $owner;

View File

@ -185,19 +185,19 @@ class UnitOfWorkTest extends \Doctrine\Tests\OrmTestCase
} }
/** /**
* @DoctrineEntity * @Entity
*/ */
class NotifyChangedEntity implements \Doctrine\Common\NotifyPropertyChanged class NotifyChangedEntity implements \Doctrine\Common\NotifyPropertyChanged
{ {
private $_listeners = array(); private $_listeners = array();
/** /**
* @DoctrineId * @Id
* @DoctrineColumn(type="integer") * @Column(type="integer")
* @DoctrineGeneratedValue(strategy="auto") * @GeneratedValue(strategy="auto")
*/ */
private $id; private $id;
/** /**
* @DoctrineColumn(type="string") * @Column(type="string")
*/ */
private $data; private $data;