[hibernate-dev] hibernate-commons-annotations and Class references

Hardy Ferentschik hardy at hibernate.org
Wed Jul 4 04:12:06 EDT 2012


On Jul 4, 2012, at 2:29 AM, Steve Ebersole wrote:

> I am working in the org.hibernate.cfg.annotations.SimpleValueBinder 
> class.  I need to be able to search for an annotation that exists either 
> on the property or on the entity that defines that property (or on one 
> of that entity's super-classes).  I have no idea how to achieve this 
> with hibernate-commons-annotations.
> 
> As far as I can tell you need to manually get the Class reference in 
> order to be able to get the XClass reference?  Is that correct?

If you don't have the XClass (or Class) yet you need indeed first get a Class
reference and then via the ReflectionManager (mappings#getReflectionManager())
get the XClass. Then you use the XClass api.

> Also, at what point, if any, during SimpleValueBinder processing can I 
> be certain that the owning entity class and its super-classes have been 
> processed?

I am not sure you can. I think the class is more of a container on which you set
properties and then at some stage you call #make(). Do you need to do this annotation
processing at a specific point in time?
Maybe you could do the processing in SimpleValueBinder#setType. There you are already
dealing with XProperty and there is a fair amount of annotation processing going on.
Not sure whether this is suitable in your case.

--Hardy




More information about the hibernate-dev mailing list