On Thu 2013-08-29 16:16, Steve Ebersole wrote:
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?
I seem to recall some case around embeddable, id or mapid where a surrogate
XProperty might be needed.
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?
Yes that makes sense to consolidate this logic in PropertyHolder. But I
have to admit I failed to find an elegant algorithm and data structure
to resolve the convert use cases you have described. All involved some
back reading of annotations etc :(
BTW is it possible to have the illegal case by mean of mixing XML and
annotation. ie you have the @Convert on the property and the disable
facility at the class level in XML. Does the same rule apply?
Because for sure the XML and the annotation are treated equally by
commons annotation.
On Thu 29 Aug 2013 03:06:37 PM CDT, Gunnar Morling wrote:
>2013/8/29 Emmanuel Bernard <emmanuel(a)hibernate.org
><mailto:emmanuel@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(a)lists.jboss.org <mailto:hibernate-dev@lists.jboss.org>
>
https://lists.jboss.org/mailman/listinfo/hibernate-dev
>
>