jsr338-experts@jpa-spec.java.net

[jsr338-experts] Clarification: BindableType

From: Oliver Gierke <ogierke_at_vmware.com>
Date: Thu, 17 Jan 2013 13:07:44 +0100

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
 */