Skip to main content

[jpa-spec users] [jsr338-experts] Re: Feature request: allow type level annotations to be used as meta-annotations

  • From: Linda DeMichiel <linda.demichiel@...>
  • To: jsr338-experts@...
  • Subject: [jpa-spec users] [jsr338-experts] Re: Feature request: allow type level annotations to be used as meta-annotations
  • Date: Thu, 17 Jan 2013 11:53:33 -0800
  • List-id: <jsr338-experts.jpa-spec.java.net>
  • Organization: Oracle Corporation

Hi Oliver,

I agree with your suggestion.  We tried to bring in a 
Metatype/Stereotype-like functionality
into Java EE 7, but ran out of runway for this release.  It is definitely on 
our roadmap
for Java EE 8 however.  You can view the discussions on the 
javaee-spec.java.net project archives.

Could you please log this in the JPA JIRA as an RFE for JPA.next?

thanks,

-Linda


On 1/17/2013 7:50 AM, Oliver Gierke wrote:
Hi all,

I repeatedly find myself annotating my JPA entities with the very same set of 
annotations:

@Entity
@EntityListeners(AuditingEntityListener.class)
class Person {

}

If both @Entity and @EntityListener were allowed to be used as 
meta-annotations I could collapse them into:

@Target(TYPE)
@Retention(RUNTIME)
@Entity
@EntityListeners(AuditingEntityListener.class)
@interface @AuditedEntity {

}

Resulting in:

@AuditedEntity
class Person {

}

This is in line with the meta-annotation handling CDI exposes to introduce 
annotation with richer semantics in annotation code [0]. The following 
changes would be required.

- Add ElementType.ANNOTATION_TYPE to the relevant annotations
- Specify that persistence providers have to evaluate the annotations from 
the meta-level as well using the first one found, so that locally defined 
annotations would be considered first.

Cheers,
Ollie

[0] https://github.com/dblevins/metatypes/



[jpa-spec users] [jsr338-experts] Feature request: allow type level annotations to be used as meta-annotations

Oliver Gierke 01/17/2013

[jpa-spec users] [jsr338-experts] Re: Feature request: allow type level annotations to be used as meta-annotations

Linda DeMichiel 01/17/2013

[jpa-spec users] [jsr338-experts] Re: Feature request: allow type level annotations to be used as meta-annotations

Oliver Gierke 01/17/2013
 
 
Close
loading
Please Confirm
Close