users@jpa-spec.java.net

[jpa-spec users] [jsr338-experts] Re: Clarification: BindableType

From: Gordon Yorke <gordon.yorke_at_oracle.com>
Date: Thu, 17 Jan 2013 09:16:20 -0400

The path in your example is a SINGULAR_ATTRIBUTE, the only time you
should expect an ENTITY_TYPE is if the Path<> represents an actual
entity like:

from.getModel().getBinableType() == ENTITY_TYPE

I do see how this question arises as the specification does not clearly
call out when each type should be returned. One has to search the
interfaces to see what interfaces extend from Bindable then it becomes
clearer.

--Gordon
On 17/01/2013 8:07 AM, Oliver Gierke wrote:
> Hi all,
>
> the metamodel API exposes a Bindable interface which in turn exposes a BindableType. Unfortunately it doesn't seem to be defined in which cases which BindableType should be returned. E.g. I have the following types:
>
> @Entity
> class Person {
> @OneToOne Address address;
> }
>
> @Entity
> class Address {
> …
> }
>
> Using the Criteria API I now try to find out that a Path instance is starting at Person is pointing to an entity effectively:
>
> Path<?> path = from.get("address");
> BindableType type = path.getModel().getBindableType();
>
> I was expecting to get ENTITY_TYPE returned but I get SINGULAR_ATTRIBUTE from a recent Hibernate. Trying to come up with a bug report for Hibernate I tried to find out what the specified behavior is but couldn't find anything except the rather brief JavaDoc.
>
> Cheers,
> Ollie