-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Transitive annotation support?
PostPosted: Fri Oct 25, 2013 9:51 am 
Newbie

Joined: Fri Oct 25, 2013 9:31 am
Posts: 1
Hi, I am supporting a project that is exploring a user defined metadata driven data model within our platform (from both our own custom annotations that carry our metadata and a UI). We have opted for JPA/Hibernate persistence in tandem with Javassist for building proxy classes. For Java developers, we are hoping to alleviate the need to always specify JPA or Hibernate annotations (or to even be aware of them with their POJOs) - so either we use reflection to generate mapping files, or provide default annotations. However, it appears Hibernate does not scan beyond first level annotations. Does anyone know a work-around for this, or if this is a feature that could be added? Example below:

@Component
@Entity
@Target(TYPE)
@Retention(value=RUNTIME)
public @interface MyAnnotation {

String name();
}

@MyAnnotation(name="test")
public class MyClass {

}

In this example, Spring will pick up MyClass as a component and register it within its bean factory, as we would like. Now we can easily scan and process any of our own annotations using Spring's classes. However, @Entity, or any other JPA/Hibernate annotations, do not appear to be processed by Hibernate. I looked a little deeper into it and saw the Hibernate's ReflectionManager uses a class called AnnotationReader that ultimately checks Java's AnnotatedElement isAnnotationPresent which ends up only looking at first level annotations and not any annotations of the annotations like Spring does.

It would be nice if we could either transitively discover JPA/Hibernate annotations that are on our custom annotations, or to have some hook into the AnnotationReader or way to override default Configuration behavior to reflectively read the full annotation graph. Is this possible?

Does anyone have any more information about this, or a work around? Thanks a lot for any help or feedback.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.