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\Query;
22 use Doctrine\ORM\Query\AST\PathExpression;
25 * Description of QueryException
28 * @link www.doctrine-project.org
30 * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
31 * @author Jonathan Wage <jonwage@gmail.com>
32 * @author Roman Borschel <roman@code-factory.org>
33 * @author Benjamin Eberlei <kontakt@beberlei.de>
35 class QueryException extends \Doctrine\ORM\ORMException
37 public static function dqlError($dql)
39 return new self($dql);
42 public static function syntaxError($message, $previous = null)
44 return new self('[Syntax Error] ' . $message, 0, $previous);
47 public static function semanticalError($message, $previous = null)
49 return new self('[Semantical Error] ' . $message, 0, $previous);
52 public static function invalidLockMode()
54 return new self('Invalid lock mode hint provided.');
57 public static function invalidParameterType($expected, $received)
59 return new self('Invalid parameter type, ' . $received . ' given, but ' . $expected . ' expected.');
62 public static function invalidParameterPosition($pos)
64 return new self('Invalid parameter position: ' . $pos);
67 public static function invalidParameterNumber()
69 return new self("Invalid parameter number: number of bound variables does not match number of tokens");
72 public static function invalidParameterFormat($value)
74 return new self('Invalid parameter format, '.$value.' given, but :<name> or ?<num> expected.');
77 public static function unknownParameter($key)
79 return new self("Invalid parameter: token ".$key." is not defined in the query.");
82 public static function parameterTypeMissmatch()
84 return new self("DQL Query parameter and type numbers missmatch, but have to be exactly equal.");
87 public static function invalidPathExpression($pathExpr)
90 "Invalid PathExpression '" . $pathExpr->identificationVariable . "." . $pathExpr->field . "'."
94 public static function invalidLiteral($literal) {
95 return new self("Invalid literal '$literal'");
101 public static function iterateWithFetchJoinCollectionNotAllowed($assoc)
104 "Invalid query operation: Not allowed to iterate over fetch join collections ".
105 "in class ".$assoc['sourceEntity']." assocation ".$assoc['fieldName']
109 public static function partialObjectsAreDangerous()
112 "Loading partial objects is dangerous. Fetch full objects or consider " .
113 "using a different fetch mode. If you really want partial objects, " .
114 "set the doctrine.forcePartialLoad query hint to TRUE."
118 public static function overwritingJoinConditionsNotYetSupported($assoc)
121 "Unsupported query operation: It is not yet possible to overwrite the join ".
122 "conditions in class ".$assoc['sourceEntityName']." assocation ".$assoc['fieldName'].". ".
123 "Use WITH to append additional join conditions to the association."
127 public static function associationPathInverseSideNotSupported()
130 "A single-valued association path expression to an inverse side is not supported".
131 " in DQL queries. Use an explicit join instead."
135 public static function iterateWithFetchJoinNotAllowed($assoc) {
137 "Iterate with fetch join in class " . $assoc['sourceEntity'] .
138 " using association " . $assoc['fieldName'] . " not allowed."
142 public static function associationPathCompositeKeyNotSupported()
145 "A single-valued association path expression to an entity with a composite primary ".
146 "key is not supported. Explicitly name the components of the composite primary key ".
151 public static function instanceOfUnrelatedClass($className, $rootClass)
153 return new self("Cannot check if a child of '" . $rootClass . "' is instanceof '" . $className . "', " .
154 "inheritance hierachy exists between these two classes.");