[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5792?page=c...
]
Thomas Pischke commented on HHH-5792:
-------------------------------------
Where this gets really ugly is when the embedded object in turn contains a collection of
entities. I see no way to join the collection contained in the component to the entity
containing the embedded component. This means it is not possible to query the collection
in the component. Hopefully I'm missing the obvious or a workaround is available.
Unable to JOIN embedded objects in Criteria API
-----------------------------------------------
Key: HHH-5792
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-5792
Project: Hibernate Core
Issue Type: Bug
Components: entity-manager, query-criteria
Affects Versions: 3.6.0
Reporter: scLee
Priority: Blocker
Attachments: Client.java, CriteriaApiTest.java, Name.java
Exception is thrown when trying to JOIN embedded attribute in Criteria API. E.g. having
the following entity:
{quote}
@Entity
public class Client implements Serializable {
@Id
public int id;
@Embedded
public Name name;
}
@Embeddable
public class Name implements Serializable {
@Column
public String firstName;
@Column
public String lastName;
}
{quote}
The following code
{quote}
CriteriaQuery< Client > cq = cb.createQuery( Client.class );
Root< Client > root = cq.from( Client.class );
cq.where( cb.equal( root.*join*( "name" ).get( "firstName" ),
"foo" ) );
{quote}
throws this exception:
{quote}
java.lang.ClassCastException: org.hibernate.ejb.metamodel.SingularAttributeImpl cannot be
cast to javax.persistence.metamodel.ManagedType
at
org.hibernate.ejb.criteria.path.AbstractFromImpl.locateManagedType(AbstractFromImpl.java:151)
at
org.hibernate.ejb.criteria.path.AbstractFromImpl.locateAttributeInternal(AbstractFromImpl.java:145)
at
org.hibernate.ejb.criteria.path.AbstractPathImpl.locateAttribute(AbstractPathImpl.java:216)
at org.hibernate.ejb.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:449)
at org.hibernate.ejb.criteria.path.AbstractFromImpl.join(AbstractFromImpl.java:433)
at foo.CriteriaApiTest.embeddableInPath(CriteriaApiTest.java:45)
{quote}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira