Skip to main content

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

  • From: Oliver Gierke <ogierke@...>
  • To: "jsr338-experts@..." <jsr338-experts@...>
  • Subject: [jpa-spec users] [jsr338-experts] Feature request: allow type level annotations to be used as meta-annotations
  • Date: Thu, 17 Jan 2013 16:50:57 +0100
  • List-id: <jsr338-experts.jpa-spec.java.net>

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/

-- 
/**
 * @author Oliver Gierke - Senior Member Technical Staff
 *
 * @param email ogierke@...
 * @param phone +49-351-30929001
 * @param fax   +49-351-418898439
 * @param skype einsdreizehn
 * @see http://www.olivergierke.de
 */


[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