class JoinedSubclassPersister extends AbstractEntityInheritancePersister (View source)

The joined subclass persister maps a single entity instance to several tables in the database as it is defined by the Class Table Inheritance strategy.

Properties

protected ClassMetadata $class Metadata object that describes the mapping of the mapped entity class. from BasicEntityPersister
protected Connection $conn The underlying DBAL Connection of the used EntityManager. from BasicEntityPersister
protected AbstractPlatform $platform The database platform. from BasicEntityPersister
protected EntityManager $em The EntityManager instance. from BasicEntityPersister
protected array $queuedInserts Queued inserts. from BasicEntityPersister
protected ResultSetMapping $rsm ResultSetMapping that is used for all queries. Is generated lazily once per request. from BasicEntityPersister
protected array $columnTypes The map of column names to DBAL mapping types of all prepared columns used when INSERTing or UPDATEing an entity. from BasicEntityPersister
protected array $quotedColumns The map of quoted column names. from BasicEntityPersister
protected string $selectColumnListSql The SELECT column list SQL fragment used for querying entities by this persister. from BasicEntityPersister
protected string $selectJoinSql The JOIN SQL fragment used to eagerly load all many-to-one and one-to-one associations configured as FETCH_EAGER, as well as all inverse one-to-one associations. from BasicEntityPersister
protected integer $sqlAliasCounter Counter for creating unique SQL table and column aliases. from BasicEntityPersister
protected array $sqlTableAliases Map from class names (FQCN) to the corresponding generated SQL table aliases. from BasicEntityPersister
protected QuoteStrategy $quoteStrategy The quote strategy. from BasicEntityPersister

Methods

__construct(EntityManager $em, ClassMetadata $class)

Initializes a new BasicEntityPersister that uses the given EntityManager and persists instances of the class described by the given ClassMetadata descriptor.

void
addInsert(object $entity)

Adds an entity to the queued insertions.

array
executeInserts()

Executes all queued entity insertions and returns any generated post-insert identifiers that were created as a result of the insertions.

void
assignDefaultVersionValue(object $entity, mixed $id)

Retrieves the default version value which was created by the preceding INSERT statement and assigns it back in to the entities version field.

mixed
fetchVersionValue(ClassMetadata $versionedClass, mixed $id)

Fetches the current version value of a versioned entity.

void
update(object $entity)

Updates a managed entity. The entity is updated according to its current changeset in the running UnitOfWork. If there is no changeset, nothing is updated.

void
updateTable(object $entity, string $quotedTableName, array $updateData, boolean $versioned = false)

Performs an UPDATE statement for an entity on a specific table.

void
deleteJoinTableRecords(array $identifier)

No description

void
delete(object $entity)

Deletes a managed entity.

array
prepareUpdateData(object $entity)

Prepares the changeset of an entity for database insertion (UPDATE).

array
prepareInsertData(object $entity)

Prepares the data changeset of a managed entity for database insertion (initial INSERT).

string
getOwningTable(string $fieldName)

Gets the name of the table that owns the column the given field is mapped to.

object|null
load(array $criteria, object|null $entity = null, array|null $assoc = null, array $hints = array(), int $lockMode = 0, int|null $limit = null, array $orderBy = null)

Loads an entity by a list of field criteria.

object
loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = array())

Loads an entity of this persister's mapped class as part of a single-valued association from another entity.

void
refresh(array $id, object $entity, int $lockMode = 0)

Refreshes a managed entity.

array
loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

array
loadAll(array $criteria = array(), array $orderBy = null, int|null $limit = null, int|null $offset = null)

Loads a list of entities by a list of field criteria.

array
getManyToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Gets (sliced or full) elements of the given collection.

array
loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $coll)

Loads a collection of entities of a many-to-many association.

string
getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int $lockMode = 0, int|null $limit = null, int|null $offset = null, array $orderBy = null)

Gets the SELECT SQL to select one or more entities by a set of field criteria.

string
getOrderBySQL(array $orderBy, string $baseTableAlias)

Gets the ORDER BY SQL snippet for ordered collections.

string
getSelectColumnsSQL()

Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly.

string
getSelectColumnAssociationSQL(string $field, array $assoc, ClassMetadata $class, string $alias = 'r')

Gets the SQL join fragment used when selecting entities from an association.

string
getSelectManyToManyJoinSQL(array $manyToMany)

Gets the SQL join fragment used when selecting entities from a many-to-many association.

string
getInsertSQL()

Gets the INSERT SQL used by the persister to persist a new entity.

array
getInsertColumnList()

Gets the list of columns to put in the INSERT SQL statement.

string
getSelectColumnSQL(string $field, ClassMetadata $class, string $alias = 'r')

Gets the SQL snippet of a qualified column name for the given field name.

string
getSQLTableAlias(string $className, string $assocName = '')

Gets the SQL table alias for the given class name.

void
lock(array $criteria, int $lockMode)

Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode.

string
getLockTablesSql(integer $lockMode)

Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister.

string
getSelectConditionCriteriaSQL(Criteria $criteria)

Gets the Select Where Condition from a Criteria object.

string
getSelectConditionStatementSQL(string $field, mixed $value, array|null $assoc = null, string|null $comparison = null)

Gets the SQL WHERE condition for matching a field with a given value.

string
getSelectConditionStatementColumnSQL(string $field, array|null $assoc = null)

Builds the left-hand-side of a where condition statement.

string
getSelectConditionSQL(array $criteria, array|null $assoc = null)

Gets the conditional SQL fragment used in the WHERE clause when selecting entities in this persister.

array
getOneToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Returns an array with (sliced or full list) of elements in the specified collection.

array
loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $coll)

Loads a collection of entities in a one-to-many association.

boolean
exists(object $entity, array $extraConditions = array())

Checks whether the given managed entity exists in the database.

string
getJoinSQLForJoinColumns(array $joinColumns)

Generates the appropriate join SQL for the given join column.

string
getSQLColumnAlias(string $columnName)

Gets an SQL column alias for a column name.

string
generateFilterConditionSQL(ClassMetadata $targetEntity, string $targetTableAlias)

Generates the filter SQL for a given entity and table alias.

string
getDiscriminatorColumnTableName()

Gets the name of the table that contains the discriminator column.

string
getSelectJoinColumnSQL(string $tableAlias, string $joinColumnName, string $className)

No description

Details

__construct(EntityManager $em, ClassMetadata $class)

Initializes a new BasicEntityPersister that uses the given EntityManager and persists instances of the class described by the given ClassMetadata descriptor.

Parameters

EntityManager $em
ClassMetadata $class

ClassMetadata getClassMetadata()

Return Value

ClassMetadata

void addInsert(object $entity)

Adds an entity to the queued insertions.

The entity remains queued until {@link executeInserts} is invoked.

Parameters

object $entity The entity to queue for insertion.

Return Value

void

array executeInserts()

Executes all queued entity insertions and returns any generated post-insert identifiers that were created as a result of the insertions.

If no inserts are queued, invoking this method is a NOOP.

Return Value

array An array of any generated post-insert IDs. This will be an empty array if the entity class does not use the IDENTITY generation strategy.

protected void assignDefaultVersionValue(object $entity, mixed $id)

Retrieves the default version value which was created by the preceding INSERT statement and assigns it back in to the entities version field.

Parameters

object $entity
mixed $id

Return Value

void

protected mixed fetchVersionValue(ClassMetadata $versionedClass, mixed $id)

Fetches the current version value of a versioned entity.

Parameters

ClassMetadata $versionedClass
mixed $id

Return Value

mixed

void update(object $entity)

Updates a managed entity. The entity is updated according to its current changeset in the running UnitOfWork. If there is no changeset, nothing is updated.

The data to update is retrieved through {@link prepareUpdateData}. Subclasses that override this method are supposed to obtain the update data in the same way, through {@link prepareUpdateData}.

Subclasses are also supposed to take care of versioning when overriding this method, if necessary. The {@link updateTable} method can be used to apply the data retrieved from {@prepareUpdateData} on the target tables, thereby optionally applying versioning.

Parameters

object $entity The entity to update.

Return Value

void

final protected void updateTable(object $entity, string $quotedTableName, array $updateData, boolean $versioned = false)

Performs an UPDATE statement for an entity on a specific table.

The UPDATE can optionally be versioned, which requires the entity to have a version field.

Parameters

object $entity The entity object being updated.
string $quotedTableName The quoted name of the table to apply the UPDATE on.
array $updateData The map of columns to update (column => value).
boolean $versioned Whether the UPDATE should be versioned.

Return Value

void

Exceptions

ORMException
OptimisticLockException

protected void deleteJoinTableRecords(array $identifier)

Parameters

array $identifier

Return Value

void

void delete(object $entity)

Deletes a managed entity.

The entity to delete must be managed and have a persistent identifier. The deletion happens instantaneously.

Subclasses may override this method to customize the semantics of entity deletion.

Parameters

object $entity The entity to delete.

Return Value

void

protected array prepareUpdateData(object $entity)

Prepares the changeset of an entity for database insertion (UPDATE).

The changeset is obtained from the currently running UnitOfWork.

During this preparation the array that is passed as the second parameter is filled with => pairs, grouped by table name.

Example: array( 'foo_table' => array('column1' => 'value1', 'column2' => 'value2', ...), 'bar_table' => array('columnX' => 'valueX', 'columnY' => 'valueY', ...), ... )

Parameters

object $entity The entity for which to prepare the data.

Return Value

array The prepared data.

protected array prepareInsertData(object $entity)

Prepares the data changeset of a managed entity for database insertion (initial INSERT).

The changeset of the entity is obtained from the currently running UnitOfWork.

The default insert data preparation is the same as for updates.

Parameters

object $entity The entity for which to prepare the data.

Return Value

array The prepared data for the tables to update.

string getOwningTable(string $fieldName)

Gets the name of the table that owns the column the given field is mapped to.

Parameters

string $fieldName The field name.

Return Value

string The table name.

object|null load(array $criteria, object|null $entity = null, array|null $assoc = null, array $hints = array(), int $lockMode = 0, int|null $limit = null, array $orderBy = null)

Loads an entity by a list of field criteria.

Parameters

array $criteria The criteria by which to load the entity.
object|null $entity The entity to load the data into. If not specified, a new entity is created.
array|null $assoc The association that connects the entity to load to another entity, if any.
array $hints Hints for entity creation.
int $lockMode
int|null $limit Limit number of results.
array $orderBy Criteria to order by.

Return Value

object|null The loaded and managed entity instance or NULL if the entity can not be found.

object loadOneToOneEntity(array $assoc, object $sourceEntity, array $identifier = array())

Loads an entity of this persister's mapped class as part of a single-valued association from another entity.

Parameters

array $assoc The association to load.
object $sourceEntity The entity that owns the association (not necessarily the "owning side").
array $identifier The identifier of the entity to load. Must be provided if the association to load represents the owning side, otherwise the identifier is derived from the $sourceEntity.

Return Value

object The loaded and managed entity instance or NULL if the entity can not be found.

Exceptions

MappingException

void refresh(array $id, object $entity, int $lockMode = 0)

Refreshes a managed entity.

Parameters

array $id The identifier of the entity as an associative array from column or field names to values.
object $entity The entity to refresh.
int $lockMode

Return Value

void

array loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

Parameters

Criteria $criteria

Return Value

array

array loadAll(array $criteria = array(), array $orderBy = null, int|null $limit = null, int|null $offset = null)

Loads a list of entities by a list of field criteria.

Parameters

array $criteria
array $orderBy
int|null $limit
int|null $offset

Return Value

array

array getManyToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Gets (sliced or full) elements of the given collection.

Parameters

array $assoc
object $sourceEntity
int|null $offset
int|null $limit

Return Value

array

array loadManyToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $coll)

Loads a collection of entities of a many-to-many association.

Parameters

array $assoc The association mapping of the association being loaded.
object $sourceEntity The entity that owns the collection.
PersistentCollection $coll The collection to fill.

Return Value

array

protected string getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int $lockMode = 0, int|null $limit = null, int|null $offset = null, array $orderBy = null)

Gets the SELECT SQL to select one or more entities by a set of field criteria.

Parameters

array|Criteria $criteria
array|null $assoc
int $lockMode
int|null $limit
int|null $offset
array $orderBy

Return Value

string

final protected string getOrderBySQL(array $orderBy, string $baseTableAlias)

Gets the ORDER BY SQL snippet for ordered collections.

Parameters

array $orderBy
string $baseTableAlias

Return Value

string

Exceptions

ORMException

protected string getSelectColumnsSQL()

Ensure this method is never called. This persister overrides getSelectEntitiesSQL directly.

Return Value

string The SQL fragment.

protected string getSelectColumnAssociationSQL(string $field, array $assoc, ClassMetadata $class, string $alias = 'r')

Gets the SQL join fragment used when selecting entities from an association.

Parameters

string $field
array $assoc
ClassMetadata $class
string $alias

Return Value

string

protected string getSelectManyToManyJoinSQL(array $manyToMany)

Gets the SQL join fragment used when selecting entities from a many-to-many association.

Parameters

array $manyToMany

Return Value

string

protected string getInsertSQL()

Gets the INSERT SQL used by the persister to persist a new entity.

Return Value

string

protected array getInsertColumnList()

Gets the list of columns to put in the INSERT SQL statement.

Subclasses should override this method to alter or change the list of columns placed in the INSERT statements used by the persister.

Return Value

array The list of columns.

protected string getSelectColumnSQL(string $field, ClassMetadata $class, string $alias = 'r')

Gets the SQL snippet of a qualified column name for the given field name.

Parameters

string $field The field name.
ClassMetadata $class The class that declares this field. The table this class is mapped to must own the column for the given field.
string $alias

Return Value

string

protected string getSQLTableAlias(string $className, string $assocName = '')

Gets the SQL table alias for the given class name.

Parameters

string $className
string $assocName

Return Value

string The SQL table alias.

void lock(array $criteria, int $lockMode)

Locks all rows of this entity matching the given criteria with the specified pessimistic lock mode.

Parameters

array $criteria
int $lockMode

Return Value

void

protected string getLockTablesSql(integer $lockMode)

Gets the FROM and optionally JOIN conditions to lock the entity managed by this persister.

Parameters

integer $lockMode One of the Doctrine\DBAL\LockMode::* constants.

Return Value

string

protected string getSelectConditionCriteriaSQL(Criteria $criteria)

Gets the Select Where Condition from a Criteria object.

Parameters

Criteria $criteria

Return Value

string

string getSelectConditionStatementSQL(string $field, mixed $value, array|null $assoc = null, string|null $comparison = null)

Gets the SQL WHERE condition for matching a field with a given value.

Parameters

string $field
mixed $value
array|null $assoc
string|null $comparison

Return Value

string

protected string getSelectConditionStatementColumnSQL(string $field, array|null $assoc = null)

Builds the left-hand-side of a where condition statement.

Parameters

string $field
array|null $assoc

Return Value

string

Exceptions

ORMException

protected string getSelectConditionSQL(array $criteria, array|null $assoc = null)

Gets the conditional SQL fragment used in the WHERE clause when selecting entities in this persister.

Subclasses are supposed to override this method if they intend to change or alter the criteria by which entities are selected.

Parameters

array $criteria
array|null $assoc

Return Value

string

array getOneToManyCollection(array $assoc, object $sourceEntity, int|null $offset = null, int|null $limit = null)

Returns an array with (sliced or full list) of elements in the specified collection.

Parameters

array $assoc
object $sourceEntity
int|null $offset
int|null $limit

Return Value

array

array loadOneToManyCollection(array $assoc, object $sourceEntity, PersistentCollection $coll)

Loads a collection of entities in a one-to-many association.

Parameters

array $assoc
object $sourceEntity
PersistentCollection $coll The collection to load/fill.

Return Value

array

boolean exists(object $entity, array $extraConditions = array())

Checks whether the given managed entity exists in the database.

Parameters

object $entity
array $extraConditions

Return Value

boolean TRUE if the entity exists in the database, FALSE otherwise.

protected string getJoinSQLForJoinColumns(array $joinColumns)

Generates the appropriate join SQL for the given join column.

Parameters

array $joinColumns The join columns definition of an association.

Return Value

string LEFT JOIN if one of the columns is nullable, INNER JOIN otherwise.

string getSQLColumnAlias(string $columnName)

Gets an SQL column alias for a column name.

Parameters

string $columnName

Return Value

string

protected string generateFilterConditionSQL(ClassMetadata $targetEntity, string $targetTableAlias)

Generates the filter SQL for a given entity and table alias.

Parameters

ClassMetadata $targetEntity Metadata of the target entity.
string $targetTableAlias The table alias of the joined/selected table.

Return Value

string The SQL query part to add to a query.

protected string getDiscriminatorColumnTableName()

Gets the name of the table that contains the discriminator column.

Return Value

string The table name.

protected string getSelectJoinColumnSQL(string $tableAlias, string $joinColumnName, string $className)

Parameters

string $tableAlias
string $joinColumnName
string $className

Return Value

string