Issue Details (XML | Word | Printable)

Key: JPA_SPEC-43
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: ldemichiel
Reporter: Oliver Gierke
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
jpa-spec

Allow type level annotations to be used as meta-annotations

Created: 17/Jan/13 08:14 PM   Updated: 05/Apr/13 12:02 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Tags: metatypes JavaEE
Participants: ldemichiel and Oliver Gierke


 Description  « Hide

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. 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.


Sort Order: Ascending order - Click to sort in descending order
ldemichiel made changes - 05/Apr/13 12:01 AM
Field Original Value New Value
Assignee ldemichiel [ ldemichiel ]
ldemichiel made changes - 05/Apr/13 12:02 AM
Tags metatypes JavaEE