Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "EclipseLink/Development/MetadataCollection"
(New page: == Metadata Collection Requirements and Design == Enhancement Request : Bug 330846 This feature will help eclipselink users to gather the metadata configurations annotated on/in se...) |
|||
Line 1: | Line 1: | ||
− | == Metadata Collection Requirements and Design == | + | == Metadata Collection Requirements and Design == |
− | Enhancement Request : Bug 330846 | + | Enhancement Request : Bug 330846 |
− | This feature will help eclipselink users to gather the metadata configurations annotated on/in several different entities on to a single centralized location (class) for better maintenence over time. The prposed feature will leverage existing standards and convensions for grouping metadata and builds upon the same to further simplify its usage and maintenence. | + | This feature will help eclipselink users to gather the metadata configurations annotated on/in several different entities on to a single centralized location (class) for better maintenence over time. The prposed feature will leverage existing standards and convensions for grouping metadata and builds upon the same to further simplify its usage and maintenence. |
+ | <br> | ||
+ | === List of Requirements: === | ||
− | + | This feature should provide eclipselink users the ability to group: | |
− | + | *all types of related named queries | |
− | + | *all related resultset mappings | |
− | *all types of related named queries | + | *all related converters |
− | *all related resultset mappings | + | |
− | *all related converters | + | |
*all related query redirectors | *all related query redirectors | ||
+ | <br> | ||
+ | at a central place like any ordinary utility class | ||
− | + | === Metadata === | |
− | + | The following sections will give in detail the changes and modifications that are required for implementing this feature. | |
− | The | + | The Metadata Collection is somewhat similar to the existing support for assembling all metatadata in eclipselink-orm.xml; however, it does not aim to be an all encompassing storehouse for the entire metadata of the project, as is the eclipselink-orm.xml. It is expected to be used to group related metadata for easier maintenance. |
− | + | <br> | |
+ | This feature will be available in both the Java annotations and XML mappings. | ||
+ | ==== Annotation: ==== | ||
− | + | ===== @MetadataCollection ===== | |
− | + | [code] | |
− | + | /** | |
− | + | A Metadata Collection can be defined on any ordinary java class to group related metadata like named queries, resultset mappings, convertors, query redirectors, etc at a central place rather than on an entity to increase reusability and clarity of code. A central location will also simplify the maintenance of these metadata. A eclipselink persistence project can have several classes that have been marked with Metadata Collection so that the users can group related metadata in to several sets for easier maintenance. | |
− | + | */ | |
− | @Target(TYPE) | + | @Target(TYPE) |
− | @Retention(RUNTIME) | + | @Retention(RUNTIME) |
− | public @interface MetadataCollection{ | + | public @interface MetadataCollection{ |
− | NamedQueries namedQueries(); | + | NamedQueries namedQueries(); |
− | NamedNativeQueries namedNativeQueries(); | + | NamedNativeQueries namedNativeQueries(); |
− | NamedStoredProcedureQueries namedStoredProcedureQueries(); | + | NamedStoredProcedureQueries namedStoredProcedureQueries(); |
− | SQLResultSetMappings[] resultSetMappings() default {}; | + | SQLResultSetMappings[] resultSetMappings() default {}; |
− | Convertors convertors(); | + | Convertors convertors(); |
− | QueryRedirectors queryRedirectors; | + | QueryRedirectors queryRedirectors; |
− | } | + | } |
− | + | [/code] | |
− | + | ==== XML Element ==== | |
− | A metadata complex xml element will be created to group all related metadata together: | + | A metadata complex xml element will be created to group all related metadata together: |
− | + | [code] | |
− | + | <xs:complexType name="metadata-collection"> | |
− | + | <xs:annotation> | |
− | < | + | <xs:documentation> |
− | </xs: | + | </xs:documentation> |
− | <xs: | + | </xs:annotation> |
− | + | <xs:sequence> | |
− | < | + | <xs:element name="namedQueries" minOccurs="0"> |
− | <xs:element | + | </xs:element> |
− | < | + | <xs:element name="namedNativeQueries" minOccurs="0"> |
− | <xs:element | + | </xs:element> |
− | < | + | <xs:element name="namedStoredProcedureQueries"> |
− | <xs:element | + | </xs:element> |
− | < | + | <xs:element name="resultSetMappings" minOccurs="0"> |
− | <xs:element | + | </xs:element> |
− | < | + | <xs:element name=convertors minOccurs="0" |
− | <xs:element | + | </xs:element> |
− | < | + | <xs:element name="query-redirectors" minOccurs="0"> |
− | </xs: | + | </xs:element> |
+ | </xs:sequence> | ||
+ | </xs:complexType> | ||
+ | [/code] | ||
+ | <br> | ||
+ | <br> | ||
+ | Example: | ||
+ | [code] | ||
+ | <metadata-collection> | ||
− | + | <named-queries> | |
− | < | + | <named-query name="" query=""/> |
− | <named- | + | </named-query> |
− | + | <named-native-queries> | |
− | < | + | <named-native-query name="" query=""/> |
− | <named-native-queries> | + | </named-native-queries> |
− | + | <named-stored-procedure-queries> | |
− | < | + | <named-stored-procedure-query name="" query="" /> |
− | <named-stored-procedure-queries> | + | </named-stored-procedure-queries> |
− | + | <result-set-mappings> | |
− | < | + | <sql-resultset-mapping> |
− | < | + | <!-- <entity>and <field> mappings --> |
− | <sql-resultset-mapping> | + | </sql-resultset-mapping> |
− | + | </resultset-mappings> | |
− | + | <convertors> | |
− | < | + | <convertor name="" class=""> |
− | < | + | </convertor> |
− | + | </convertors> | |
− | + | <query-redirectors> | |
− | </ | + | <query-redirector allqueries="DefaultRedirector.class"/> |
− | <query-redirectors> | + | </query-redirectors> |
− | + | </metadata-collection> | |
− | + | [/code] | |
− | + | | |
which can be annotated on any ordinary top level java class to group metadata that belongs to more than one entity. | which can be annotated on any ordinary top level java class to group metadata that belongs to more than one entity. |
Revision as of 13:37, 30 November 2010
Contents
Metadata Collection Requirements and Design
Enhancement Request : Bug 330846
This feature will help eclipselink users to gather the metadata configurations annotated on/in several different entities on to a single centralized location (class) for better maintenence over time. The prposed feature will leverage existing standards and convensions for grouping metadata and builds upon the same to further simplify its usage and maintenence.
List of Requirements:
This feature should provide eclipselink users the ability to group:
- all types of related named queries
- all related resultset mappings
- all related converters
- all related query redirectors
at a central place like any ordinary utility class
Metadata
The following sections will give in detail the changes and modifications that are required for implementing this feature.
The Metadata Collection is somewhat similar to the existing support for assembling all metatadata in eclipselink-orm.xml; however, it does not aim to be an all encompassing storehouse for the entire metadata of the project, as is the eclipselink-orm.xml. It is expected to be used to group related metadata for easier maintenance.
This feature will be available in both the Java annotations and XML mappings.
Annotation:
@MetadataCollection
[code]
/**
A Metadata Collection can be defined on any ordinary java class to group related metadata like named queries, resultset mappings, convertors, query redirectors, etc at a central place rather than on an entity to increase reusability and clarity of code. A central location will also simplify the maintenance of these metadata. A eclipselink persistence project can have several classes that have been marked with Metadata Collection so that the users can group related metadata in to several sets for easier maintenance.
- /
@Target(TYPE)
@Retention(RUNTIME)
public @interface MetadataCollection{
NamedQueries namedQueries();
NamedNativeQueries namedNativeQueries();
NamedStoredProcedureQueries namedStoredProcedureQueries();
SQLResultSetMappings[] resultSetMappings() default {};
Convertors convertors();
QueryRedirectors queryRedirectors;
}
[/code]
XML Element
A metadata complex xml element will be created to group all related metadata together:
[code]
<xs:complexType name="metadata-collection">
<xs:annotation>
<xs:documentation>
</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="namedQueries" minOccurs="0">
</xs:element>
<xs:element name="namedNativeQueries" minOccurs="0">
</xs:element>
<xs:element name="namedStoredProcedureQueries">
</xs:element>
<xs:element name="resultSetMappings" minOccurs="0">
</xs:element>
<xs:element name=convertors minOccurs="0"
</xs:element>
<xs:element name="query-redirectors" minOccurs="0">
</xs:element>
</xs:sequence>
</xs:complexType>
[/code]
Example:
[code]
<metadata-collection>
<named-queries>
<named-query name="" query=""/>
</named-query>
<named-native-queries>
<named-native-query name="" query=""/>
</named-native-queries>
<named-stored-procedure-queries>
<named-stored-procedure-query name="" query="" />
</named-stored-procedure-queries>
<result-set-mappings>
<sql-resultset-mapping>
<!-- <entity>and <field> mappings -->
</sql-resultset-mapping>
</resultset-mappings>
<convertors>
<convertor name="" class="">
</convertor>
</convertors>
<query-redirectors>
<query-redirector allqueries="DefaultRedirector.class"/>
</query-redirectors>
</metadata-collection>
[/code]
which can be annotated on any ordinary top level java class to group metadata that belongs to more than one entity.