As a follow up: I am now falling back on checking whether BindableType is a SingluarAttribute and invoking ….isAssociation() on it. If that fails, I inspect the persistentAttributeType for being one of the association annotations.
Quite a wild ride actually but there doesn't seem to be an easier way without having direct access to the Metamodel.
Cheers,
Ollie
Am 17.01.2013 um 13:07 schrieb Oliver Gierke <ogierke_at_vmware.com>:
> 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
> --
> /**
> * @author Oliver Gierke - Senior Member Technical Staff
> *
> * @param email ogierke_at_vmware.com
> * @param phone +49-351-30929001
> * @param fax +49-351-418898439
> * @param skype einsdreizehn
> * @see http://www.olivergierke.de
> */
--
/**
* @author Oliver Gierke - Senior Member Technical Staff
*
* @param email ogierke_at_vmware.com
* @param phone +49-351-30929001
* @param fax +49-351-418898439
* @param skype einsdreizehn
* @see http://www.olivergierke.de
*/