From 530e4840dd93357033b93a380be687231b430388 Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Sat, 25 Feb 2012 19:58:59 -0200 Subject: [PATCH] native query annotations --- lib/Doctrine/ORM/Mapping/EntityResult.php | 58 +++++++++++++++++ lib/Doctrine/ORM/Mapping/FieldResult.php | 48 ++++++++++++++ .../ORM/Mapping/NamedNativeQueries.php | 40 ++++++++++++ lib/Doctrine/ORM/Mapping/NamedNativeQuery.php | 63 +++++++++++++++++++ .../ORM/Mapping/SqlResultSetMapping.php | 56 +++++++++++++++++ .../ORM/Mapping/SqlResultSetMappings.php | 40 ++++++++++++ 6 files changed, 305 insertions(+) create mode 100644 lib/Doctrine/ORM/Mapping/EntityResult.php create mode 100644 lib/Doctrine/ORM/Mapping/FieldResult.php create mode 100644 lib/Doctrine/ORM/Mapping/NamedNativeQueries.php create mode 100644 lib/Doctrine/ORM/Mapping/NamedNativeQuery.php create mode 100644 lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php create mode 100644 lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php diff --git a/lib/Doctrine/ORM/Mapping/EntityResult.php b/lib/Doctrine/ORM/Mapping/EntityResult.php new file mode 100644 index 000000000..ae83d52c2 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/EntityResult.php @@ -0,0 +1,58 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * References an entity in the SELECT clause of a SQL query. + * If this annotation is used, the SQL statement should select all of the columns that are mapped to the entity object. + * This should include foreign key columns to related entities. + * The results obtained when insufficient data is available are undefined. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("ANNOTATION") + */ +final class EntityResult implements Annotation +{ + + /** + * The class of the result + * + * @var string + */ + public $entityClass; + + /** + * Maps the columns specified in the SELECT list of the query to the properties or fields of the entity class. + * + * @var array<\Doctrine\ORM\Mapping\FieldResult> + */ + public $fields; + + /** + * Specifies the column name of the column in the SELECT list that is used to determine the type of the entity instance. + * + * @var string + */ + public $discriminatorColumn; + +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/FieldResult.php b/lib/Doctrine/ORM/Mapping/FieldResult.php new file mode 100644 index 000000000..c2c49c68d --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/FieldResult.php @@ -0,0 +1,48 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * Is used to map the columns specified in the SELECT list of the query to the properties or fields of the entity class. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("ANNOTATION") + */ +final class FieldResult implements Annotation +{ + + /** + * Name of the column in the SELECT clause. + * + * @var string + */ + public $name; + + /** + * Name of the persistent field or property of the class. + * + * @var string + */ + public $column; + +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php b/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php new file mode 100644 index 000000000..f957f4ed2 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/NamedNativeQueries.php @@ -0,0 +1,40 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * Is used to specify an array of native SQL named queries. + * The NamedNativeQueries annotation can be applied to an entity or mapped superclass. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("CLASS") + */ +final class NamedNativeQueries implements Annotation +{ + /** + * One or more NamedNativeQuery annotations. + * + * @var array<\Doctrine\ORM\Mapping\NamedNativeQuery> + */ + public $value; +} diff --git a/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php b/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php new file mode 100644 index 000000000..f7c604461 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/NamedNativeQuery.php @@ -0,0 +1,63 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * Is used to specify a native SQL named query. + * The NamedNativeQuery annotation can be applied to an entity or mapped superclass. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("CLASS") + */ +final class NamedNativeQuery implements Annotation +{ + + /** + * The name used to refer to the query with the EntityManager methods that create query objects. + * + * @var string + */ + public $name; + + /** + * The SQL query string. + * + * @var string + */ + public $query; + + /** + * The class of the result. + * + * @var string + */ + public $resultClass; + + /** + * The name of a SqlResultSetMapping, as defined in metadata. + * + * @var string + */ + public $resultSetMapping; + +} diff --git a/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php b/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php new file mode 100644 index 000000000..a3bc5b4c9 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/SqlResultSetMapping.php @@ -0,0 +1,56 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * The SqlResultSetMapping annotation is used to specify the mapping of the result of a native SQL query. + * The SqlResultSetMapping annotation can be applied to an entity or mapped superclass. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("CLASS") + */ +final class SqlResultSetMapping implements Annotation +{ + + /** + * The name given to the result set mapping, and used to refer to it in the methods of the Query API. + * + * @var string + */ + public $name; + + /** + * Specifies the result set mapping to entities. + * + * @var array<\Doctrine\ORM\Mapping\EntityResult> + */ + public $entities; + + /** + * Specifies the result set mapping to scalar values. + * + * @var array<\Doctrine\ORM\Mapping\ColumnResult> + */ + public $columns; + +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php b/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php new file mode 100644 index 000000000..889924bbc --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/SqlResultSetMappings.php @@ -0,0 +1,40 @@ +. + */ + +namespace Doctrine\ORM\Mapping; + +/** + * Is used to specify an array of mappings. + * The SqlResultSetMappings annotation can be applied to an entity or mapped superclass. + * + * @author Fabio B. Silva + * @since 2.3 + * + * @Annotation + * @Target("CLASS") + */ +final class SqlResultSetMappings implements Annotation +{ + /** + * One or more SqlResultSetMapping annotations. + * + * @var array<\Doctrine\ORM\Mapping\SqlResultSetMapping> + */ + public $value; +}