3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\ORM;
25 * Base exception class for all ORM exceptions.
27 * @author Roman Borschel <roman@code-factory.org>
30 class ORMException extends Exception
32 public static function missingMappingDriverImpl()
34 return new self("It's a requirement to specify a Metadata Driver and pass it ".
35 "to Doctrine\\ORM\\Configuration::setMetadataDriverImpl().");
38 public static function namedQueryNotFound($queryName)
40 return new self('Could not find a named query by the name "' . $queryName . '"');
43 public static function namedNativeQueryNotFound($nativeQueryName)
45 return new self('Could not find a named native query by the name "' . $nativeQueryName . '"');
48 public static function entityMissingForeignAssignedId($entity, $relatedEntity)
51 "Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " .
52 "however this entity has no identity itself. You have to call EntityManager#persist() on the related entity " .
53 "and make sure that an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
54 "of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " .
55 "EntityManager#flush() between both persist operations."
59 public static function entityMissingAssignedIdForField($entity, $field)
61 return new self("Entity of type " . get_class($entity) . " is missing an assigned ID for field '" . $field . "'. " .
62 "The identifier generation strategy for this entity requires the ID field to be populated before ".
63 "EntityManager#persist() is called. If you want automatically generated identifiers instead " .
64 "you need to adjust the metadata mapping accordingly."
68 public static function unrecognizedField($field)
70 return new self("Unrecognized field: $field");
74 * @param string $className
75 * @param string $field
77 public static function invalidOrientation($className, $field)
79 return new self("Invalid order by orientation specified for " . $className . "#" . $field);
82 public static function invalidFlushMode($mode)
84 return new self("'$mode' is an invalid flush mode.");
87 public static function entityManagerClosed()
89 return new self("The EntityManager is closed.");
92 public static function invalidHydrationMode($mode)
94 return new self("'$mode' is an invalid hydration mode.");
97 public static function mismatchedEventManager()
99 return new self("Cannot use different EventManager instances for EntityManager and Connection.");
102 public static function findByRequiresParameter($methodName)
104 return new self("You need to pass a parameter to '".$methodName."'");
107 public static function invalidFindByCall($entityName, $fieldName, $method)
110 "Entity '".$entityName."' has no field '".$fieldName."'. ".
111 "You can therefore not call '".$method."' on the entities' repository"
115 public static function invalidFindByInverseAssociation($entityName, $associationFieldName)
118 "You cannot search for the association field '".$entityName."#".$associationFieldName."', ".
119 "because it is the inverse side of an association. Find methods only work on owning side associations."
123 public static function invalidResultCacheDriver() {
124 return new self("Invalid result cache driver; it must implement Doctrine\\Common\\Cache\\Cache.");
127 public static function notSupported() {
128 return new self("This behaviour is (currently) not supported by Doctrine 2");
131 public static function queryCacheNotConfigured()
133 return new self('Query Cache is not configured.');
136 public static function metadataCacheNotConfigured()
138 return new self('Class Metadata Cache is not configured.');
141 public static function proxyClassesAlwaysRegenerating()
143 return new self('Proxy Classes are always regenerating.');
146 public static function unknownEntityNamespace($entityNamespaceAlias)
149 "Unknown Entity namespace alias '$entityNamespaceAlias'."
153 public static function invalidEntityRepository($className)
155 return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
158 public static function missingIdentifierField($className, $fieldName)
160 return new self("The identifier $fieldName is missing for a query of " . $className);
163 public static function overwriteInternalDQLFunctionNotAllowed($functionName)
165 return new self("It is not allowed to overwrite internal function '$functionName' in the DQL parser through user-defined functions.");