[hibernate-dev] hiberate-commons-annotations and locating annotations
Steve Ebersole
steve at hibernate.org
Thu Aug 29 17:16:48 EDT 2013
Ok, so given the initial Super/Sub setup, what we get in
SimpleValueBinder#setType is this:
1) The XProperty passed in is defined as follows:
a) It is a JavaXProperty speciffically
b) Its 'annotatedElement' attribute (not exposed) is the
java.lang.reflect.Field for the Super#it field.
c) Interestingly, the SimpleValueBinder#xproperty is the same exact
instance. Can these ever be different?
2) The 'declaringClassName' passed in to SimpleValueBinder#setType is
Sub. So maybe we can leverage that. But
org.hibernate.cfg.annotations.PropertyBinder#makePropertyAndValue (the
main caller of this method) has explicit handle for null-ness so that
makes me nervous.
Given the differing rules for resolving converter to use for basic
types, collections and composites and the fact that these distinctions
are already handled in the PropertyHolder hierarchy, I think it would
be better to handle those distinctions there. Either adding a separate
method to inject the converter to use (making sure it is called before
setType, ugh) or changing the signature of setType to accept the
converter to use. PropertyBinder#makePropertyAndValue would then use
PropertyHolder#resolveAttributeConverter to pass what it needs to pass.
WDYT?
On Thu 29 Aug 2013 03:06:37 PM CDT, Gunnar Morling wrote:
> 2013/8/29 Emmanuel Bernard <emmanuel at hibernate.org
> <mailto:emmanuel at hibernate.org>>
>
> On Thu 2013-08-29 14:22, Steve Ebersole wrote:
> > Given an XProperty, is there a way to ask for annotations which are
> > defined only locally on that declared property (not on any super
> classes)?
>
> I believe that is what XProperty will give you.
> The list of XProperty of a given XClass is computed from
> Class.getDeclaredMethod, so it does not look for superclass methods.
>
> Could it be that @Convert is marked @Inherited?
>
>
> @Inherited applies to annotations on classes only, it has no effect
> for annotations on properties.
>
> _______________________________________________
> hibernate-dev mailing list
> hibernate-dev at lists.jboss.org <mailto:hibernate-dev at lists.jboss.org>
> https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>
More information about the hibernate-dev
mailing list