[ 
https://issues.apache.org/jira/browse/JDO-764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andy Jefferson updated JDO-764:
-------------------------------
    Description: 
By default annotations are used directly in a persistable class. Java 
additionally allows annotations to be formed of other annotations. This is 
particularly useful where a user has a particular combination of annotations to 
set on a class/field/method and wants to simply annotate with an abbreviated 
form. For example, specifying attributes of an annotation

@PersistenceCapable(detachable="true", identityType="datastore", 
embeddedOnly="true")

or formed of multiple annotations

@PersistenceCapable(detachable="true")
@Extension(vendorName="datanucleus", key="multitenancy-column-name", 
value="TENANT")

These can be represented as meta-annotations like this

@Target(TYPE)
@Retention(RUNTIME)
@PersistenceCapable(detachable="true", identityType="datastore", 
embeddedOnly="true")
public @interface DatastoreIdPersistable
{
}

@Target(TYPE)
@Retention(RUNTIME)
@PersistenceCapable(detachable="true")
@Extension(vendorName="datanucleus", key="multitenancy-column-name", 
value="TENANT")
public @interface MultitenantPersistable
{
}

and the user can subsequently just annotate their persistable class as

@DatastoreIdPersistable
public class MyClass1 {...}


@MultitenantPersistable
public class MyClass2 {...}

The work required to support this in the JDO spec is simply to update the 
following annotations to add @Target({ElementType.ANNOTATION_TYPE})

The annotations requiring this are
@Element, @EmbeddedId, @Key, @NotPersistent, @Order, @Persistent, @Serialized, 
@Transactional, and @Value  (all other annotations already have 
@Target({ElementType.TYPE}) which already permits their usage in 
meta-annotations.

The same is proposed for JPA 2.2, see 
https://github.com/javaee/jpa-spec/issues/43

  was:
By default annotations are used directly in a persistable class. Java 
additionally allows annotations to be formed of other annotations. This is 
particularly useful where a user has a particular combination of annotations to 
set on a class/field/method and wants to simply annotate with an abbreviated 
form. For example, specifying attributes of an annotation

@PersistenceCapable(detachable="true", identityType="datastore", 
embeddedOnly="true")

or formed of multiple annotations

@PersistenceCapable(detachable="true")
@Extension(vendorName="datanucleus", key="multitenancy-column-name", 
value="TENANT")

These can be represented as meta-annotations like this

@Target(TYPE)
@Retention(RUNTIME)
@PersistenceCapable(detachable="true", identityType="datastore", 
embeddedOnly="true")
@interface @DatastoreIdPersistable
{
}

@Target(TYPE)
@Retention(RUNTIME)
@PersistenceCapable(detachable="true")
@Extension(vendorName="datanucleus", key="multitenancy-column-name", 
value="TENANT")
@interface @MultitenantPersistable
{
}

and the user can subsequently just annotate their persistable class as

@DatastoreIdPersistable
public class MyClass1 {...}


@MultitenantPersistable
public class MyClass2 {...}

The work required to support this in the JDO spec is simply to update the 
following annotations to add @Target({ElementType.ANNOTATION_TYPE})

The annotations requiring this are
@Element, @EmbeddedId, @Key, @NotPersistent, @Order, @Persistent, @Serialized, 
@Transactional, and @Value  (all other annotations already have 
@Target({ElementType.TYPE}) which already permits their usage in 
meta-annotations.

The same is proposed for JPA 2.2, see 
https://github.com/javaee/jpa-spec/issues/43


> Allow JDO annotations to be used in meta-annotations
> ----------------------------------------------------
>
>                 Key: JDO-764
>                 URL: https://issues.apache.org/jira/browse/JDO-764
>             Project: JDO
>          Issue Type: Improvement
>          Components: api, specification
>    Affects Versions: JDO 3.1
>            Reporter: Andy Jefferson
>             Fix For: JDO 3.2
>
>         Attachments: JDO-764.patch
>
>
> By default annotations are used directly in a persistable class. Java 
> additionally allows annotations to be formed of other annotations. This is 
> particularly useful where a user has a particular combination of annotations 
> to set on a class/field/method and wants to simply annotate with an 
> abbreviated form. For example, specifying attributes of an annotation
> @PersistenceCapable(detachable="true", identityType="datastore", 
> embeddedOnly="true")
> or formed of multiple annotations
> @PersistenceCapable(detachable="true")
> @Extension(vendorName="datanucleus", key="multitenancy-column-name", 
> value="TENANT")
> These can be represented as meta-annotations like this
> @Target(TYPE)
> @Retention(RUNTIME)
> @PersistenceCapable(detachable="true", identityType="datastore", 
> embeddedOnly="true")
> public @interface DatastoreIdPersistable
> {
> }
> @Target(TYPE)
> @Retention(RUNTIME)
> @PersistenceCapable(detachable="true")
> @Extension(vendorName="datanucleus", key="multitenancy-column-name", 
> value="TENANT")
> public @interface MultitenantPersistable
> {
> }
> and the user can subsequently just annotate their persistable class as
> @DatastoreIdPersistable
> public class MyClass1 {...}
> @MultitenantPersistable
> public class MyClass2 {...}
> The work required to support this in the JDO spec is simply to update the 
> following annotations to add @Target({ElementType.ANNOTATION_TYPE})
> The annotations requiring this are
> @Element, @EmbeddedId, @Key, @NotPersistent, @Order, @Persistent, 
> @Serialized, @Transactional, and @Value  (all other annotations already have 
> @Target({ElementType.TYPE}) which already permits their usage in 
> meta-annotations.
> The same is proposed for JPA 2.2, see 
> https://github.com/javaee/jpa-spec/issues/43



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to