-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DDC-1184 - Improve error handling in AssignedIdGenerator
- Loading branch information
Showing
2 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,10 +34,25 @@ public static function missingMappingDriverImpl() | |
return new self("It's a requirement to specify a Metadata Driver and pass it ". | ||
"to Doctrine\ORM\Configuration::setMetadataDriverImpl()."); | ||
} | ||
|
||
public static function entityMissingForeignAssignedId($entity, $relatedEntity) | ||
{ | ||
return new self( | ||
"Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntityClass) . ", " . | ||
"however this entity has no ientity itself. You have to call EntityManager#persist() on the related entity " . | ||
This comment has been minimized.
Sorry, something went wrong.
guilhermeblanco
Member
|
||
"and make sure it an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " . | ||
"of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " . | ||
"EntityManager#flush() between both persist operations." | ||
); | ||
} | ||
|
||
public static function entityMissingAssignedId($entity) | ||
{ | ||
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID."); | ||
return new self("Entity of type " . get_class($entity) . " is missing an assigned ID. " . | ||
"The identifier generation strategy for this entity requires the ID field to be populated before ". | ||
"EntityManager#persist() is called. If you want automatically generated identifiers instead " . | ||
"you need to adjust the metadata mapping accordingly." | ||
); | ||
} | ||
|
||
public static function unrecognizedField($field) | ||
|
Cascade persist doesn't work if associated object relies on parents auto generated ID, even if it has only one primary key!