Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

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:  ===
  
===== List of Requirements: =====
+
&nbsp;&nbsp; This feature should provide eclipselink users the ability to group:  
  
&nbsp;&nbsp; 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 &nbsp;&nbsp;
 
*all related query redirectors &nbsp;&nbsp;
  
 +
<br>
  
 +
at a central place like any ordinary utility class
  
at a central place like any ordinary utility class
+
=== Metadata  ===
  
== Metadata ==
+
The following sections will give in detail the changes and modifications that are required for implementing this feature.
  
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.  
  
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 &nbsp;feature will be available in both the Java annotations and XML mappings.
  
 +
==== Annotation:  ====
  
This &nbsp;feature will be available in both the Java annotations and XML mappings.
+
===== &nbsp;&nbsp;@MetadataCollection  =====
  
====== Annotation: ======
+
[code]
  
==== &nbsp;&nbsp;@MetadataCollection ====
+
/**
  
/**
+
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{  
  
&nbsp;&nbsp; &nbsp;NamedQueries namedQueries();
+
&nbsp;&nbsp; &nbsp;NamedQueries namedQueries();  
  
&nbsp;&nbsp; &nbsp;NamedNativeQueries namedNativeQueries();
+
&nbsp;&nbsp; &nbsp;NamedNativeQueries namedNativeQueries();  
  
&nbsp;&nbsp; &nbsp;NamedStoredProcedureQueries namedStoredProcedureQueries();
+
&nbsp;&nbsp; &nbsp;NamedStoredProcedureQueries namedStoredProcedureQueries();  
  
&nbsp;&nbsp; &nbsp;SQLResultSetMappings[] resultSetMappings() default {};
+
&nbsp;&nbsp; &nbsp;SQLResultSetMappings[] resultSetMappings() default {};  
  
&nbsp;&nbsp; &nbsp;Convertors convertors();
+
&nbsp;&nbsp; &nbsp;Convertors convertors();  
  
&nbsp;&nbsp; &nbsp;QueryRedirectors queryRedirectors;
+
&nbsp;&nbsp; &nbsp;QueryRedirectors queryRedirectors;  
  
}
+
}  
  
<br>
+
[/code]
  
====== XML Element ======
+
==== 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:  
  
&lt;xs:complexType name="metadata-collection"&gt;
+
[code]
  
&nbsp;&nbsp; &nbsp;&lt;xs:annotation&gt;
+
&lt;xs:complexType name="metadata-collection"&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;xs:documentation&gt;
+
&nbsp;&nbsp; &nbsp; &lt;xs:annotation&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xs:documentation&gt;&nbsp;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;xs:documentation&gt;  
  
&nbsp;&nbsp; &nbsp;&lt;/xs:annotation&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/xs:documentation&gt;&nbsp;  
  
&nbsp;&nbsp; &nbsp;&lt;xs:sequence&gt;
+
&nbsp;&nbsp; &nbsp; &lt;/xs:annotation&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedQueries" &nbsp;minOccurs="0"&gt;
+
&nbsp;&nbsp; &nbsp; &lt;xs:sequence&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedQueries" &nbsp;minOccurs="0"&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedNativeQueries" minOccurs="0"&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedNativeQueries" minOccurs="0"&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedStoredProcedureQueries"&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="namedStoredProcedureQueries"&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="resultSetMappings" minOccurs="0"&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="resultSetMappings" minOccurs="0"&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name=convertors minOccurs="0"
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name=convertors minOccurs="0"
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="query-redirectors" minOccurs="0"&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;xs:element name="query-redirectors" minOccurs="0"&gt;  
  
&lt;/xs:complexType&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/xs:element&gt;  
  
 +
&nbsp;&nbsp; &nbsp; &nbsp;&lt;/xs:sequence&gt;
  
 +
&lt;/xs:complexType&gt;
  
 +
[/code]
  
 +
<br>
  
 +
<br>
  
 +
Example:
  
 +
[code]
  
 +
&lt;metadata-collection&gt;
  
Example:
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;named-queries&gt;
  
&lt;metadata-collection&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;named-query name="" query=""/&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;named-queries&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/named-query&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;named-query name="" query=""/&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;named-native-queries&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;/named-query&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;named-native-query name="" query=""/&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&lt;named-native-queries&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/named-native-queries&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;named-native-query name="" query=""/&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;named-stored-procedure-queries&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/named-native-queries&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;named-stored-procedure-query name="" query="" /&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;named-stored-procedure-queries&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/named-stored-procedure-queries&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;named-stored-procedure-query name="" query="" /&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;result-set-mappings&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/named-stored-procedure-queries&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;sql-resultset-mapping&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;result-set-mappings&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- &lt;entity&gt;and &lt;field&gt; mappings --&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;sql-resultset-mapping&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/sql-resultset-mapping&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- &lt;entity&gt;and &lt;field&gt; mappings --&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/resultset-mappings&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/sql-resultset-mapping&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;convertors&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/resultset-mappings&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;convertor name="" class=""&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;convertors&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/convertor&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;convertor name="" class=""&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/convertors&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/convertor&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;query-redirectors&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &lt;/convertors&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;query-redirector allqueries="DefaultRedirector.class"/&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;query-redirectors&gt;
+
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query-redirectors&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;query-redirector allqueries="DefaultRedirector.class"/&gt;
+
&lt;/metadata-collection&gt;  
  
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/query-redirectors&gt;
+
[/code]
  
&lt;/metadata-collection&gt; &nbsp;
+
&nbsp;
  
 
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

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.

Back to the top