[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5976) ClassCastException when accessing attributes of embedded object through Join structure.

Jaroslaw Lewandowski (JIRA) noreply at atlassian.com
Thu Mar 3 12:43:08 EST 2011


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=40102#action_40102 ] 

Jaroslaw Lewandowski commented on HHH-5976:
-------------------------------------------

Correction: join.get(Attribute ...) works okay.. the problem I'm having is with join.get("attributeName"); attribute name passed as string

> ClassCastException when accessing attributes of embedded object through Join structure.
> ---------------------------------------------------------------------------------------
>
>                 Key: HHH-5976
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5976
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: query-criteria
>    Affects Versions: 3.6.0
>            Reporter: Jaroslaw Lewandowski
>
> Suppose you have class A which has attribute 'a' of type E which is @Embedded type. The following code using criteria API will throw ClassCastExeption
> {code}
> Root<A> root =...
> Join<A,E> join = root.join(A_.e);
> join.get(E_.attribute);  <=== accessing any attribute of E will throw ClassCastExeption. With the following stack trace:\
> {code}
> {code}
> 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.AbstractPathImpl.get(AbstractPathImpl.java:189)
> {code}

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