[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5792) Unable to JOIN embedded objects in Criteria API

scLee (JIRA) noreply at atlassian.com
Wed Dec 15 11:27:13 EST 2010


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.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the hibernate-issues mailing list