abstract class AbstractEntityPersister implements CachedEntityPersister (View source)

Properties

protected UnitOfWork $uow
protected ClassMetadataFactory $metadataFactory
protected EntityPersister $persister
protected ClassMetadata $class
protected array $queuedCache
protected Region $region
protected TimestampRegion $timestampRegion
protected TimestampCacheKey $timestampKey
protected EntityHydrator $hydrator
protected Cache $cache
protected CacheLogger $cacheLogger
protected string $regionName
protected array $joinedAssociations Associations configured as FETCH_EAGER, as well as all inverse one-to-one associations.

Methods

__construct(EntityPersister $persister, Region $region, EntityManagerInterface $em, ClassMetadata $class)

No description

void
addInsert(object $entity)

Adds an entity to the queued insertions.

array
getInserts()

Get all queued inserts.

string
getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int|null $lockMode = null, 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
getCountSQL(array|Criteria $criteria = array())

Get the COUNT SQL to count entities (optionally based on a criteria)

string
getInsertSQL()

No description

getResultSetMapping()

Gets the ResultSetMapping used for hydration.

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.

boolean
exists(object $entity, Criteria $extraConditions = null)

Checks whether the given managed entity exists in the database.

getCacheRegion()

Gets the The region access.

boolean
storeEntityCache(object $entity, EntityCacheKey $key)

No description

string
getHash(array $query, string $criteria, array $orderBy = null, integer $limit = null, integer $offset = null)

Generates a string of currently query

array
expandParameters($criteria)

Expands the parameters from the given criteria and use the correct binding types if found.

array
expandCriteriaParameters(Criteria $criteria)

Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it.

getClassMetadata()

No description

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

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

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.

string
getOwningTable(string $fieldName)

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

array
executeInserts()

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

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

Loads an entity by a list of field criteria.

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.

object
loadById(array $identifier, object|null $entity = null)

Loads an entity by identifier.

int
count(array|Criteria $criteria = array())

Count entities (optionally filtered by a criteria)

array
loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

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

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

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

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

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
lock(array $criteria, int $lockMode)

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

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

Refreshes a managed entity.

Details

__construct(EntityPersister $persister, Region $region, EntityManagerInterface $em, ClassMetadata $class)

Parameters

EntityPersister $persister The entity persister to cache.
Region $region The entity cache region.
EntityManagerInterface $em The entity manager.
ClassMetadata $class The entity metadata.

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 getInserts()

Get all queued inserts.

Return Value

array

string getSelectSQL(array|Criteria $criteria, array|null $assoc = null, int|null $lockMode = null, 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|null $lockMode
int|null $limit
int|null $offset
array $orderBy

Return Value

string

string getCountSQL(array|Criteria $criteria = array())

Get the COUNT SQL to count entities (optionally based on a criteria)

Parameters

array|Criteria $criteria

Return Value

string

string getInsertSQL()

Return Value

string

ResultSetMapping getResultSetMapping()

Gets the ResultSetMapping used for hydration.

Return Value

ResultSetMapping

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

boolean exists(object $entity, Criteria $extraConditions = null)

Checks whether the given managed entity exists in the database.

Parameters

object $entity
Criteria $extraConditions

Return Value

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

Region getCacheRegion()

Gets the The region access.

Return Value

Region

EntityHydrator getEntityHydrator()

Return Value

EntityHydrator

boolean storeEntityCache(object $entity, EntityCacheKey $key)

Parameters

object $entity
EntityCacheKey $key

Return Value

boolean

protected string getHash(array $query, string $criteria, array $orderBy = null, integer $limit = null, integer $offset = null)

Generates a string of currently query

Parameters

array $query
string $criteria
array $orderBy
integer $limit
integer $offset

Return Value

string

array expandParameters($criteria)

Expands the parameters from the given criteria and use the correct binding types if found.

Parameters

$criteria

Return Value

array

array expandCriteriaParameters(Criteria $criteria)

Expands Criteria Parameters by walking the expressions and grabbing all parameters and types from it.

Parameters

Criteria $criteria

Return Value

array

ClassMetadata getClassMetadata()

Return Value

ClassMetadata

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 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

string getOwningTable(string $fieldName)

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

The default implementation in BasicEntityPersister always returns the name of the table the entity type of this persister is mapped to, since an entity is always persisted to a single table with a BasicEntityPersister.

Parameters

string $fieldName The field name.

Return Value

string The table name.

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.

object|null load(array $criteria, object|null $entity = null, array|null $assoc = null, array $hints = array(), int|null $lockMode = null, 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|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used for loading the entity.
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.

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

object loadById(array $identifier, object|null $entity = null)

Loads an entity by identifier.

Parameters

array $identifier The entity identifier.
object|null $entity The entity to load the data into. If not specified, a new entity is created.

Return Value

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

int count(array|Criteria $criteria = array())

Count entities (optionally filtered by a criteria)

Parameters

array|Criteria $criteria

Return Value

int

array loadCriteria(Criteria $criteria)

Loads Entities matching the given Criteria object.

Parameters

Criteria $criteria

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

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

Return Value

array

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 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 One of the Doctrine\DBAL\LockMode::* constants.

Return Value

void

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

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|null $lockMode One of the \Doctrine\DBAL\LockMode::* constants or NULL if no specific lock mode should be used for refreshing the managed entity.

Return Value

void