[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-4581) Embedded objects in criteria API does not work

Gabriel Lee (JIRA) noreply at atlassian.com
Wed Dec 15 10:15:13 EST 2010


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

Gabriel Lee commented on HHH-4581:
----------------------------------

In 3.6-Final the above code sample fails if I use "join" instead of "get":

cq.where(cb.equal(root.join(Client_.name).join(Name_.firstName)), "blah");

Is it a bug? 

> Embedded objects in criteria API does not work
> ----------------------------------------------
>
>                 Key: HHH-4581
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-4581
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: entity-manager, query-criteria
>    Affects Versions: 3.5.0-Beta-2
>            Reporter: Jaroslaw Lewandowski
>            Assignee: Steve Ebersole
>            Priority: Blocker
>             Fix For: 3.5.0-Beta-3
>
>         Attachments: Client.java, CriteriaApiTest.java, Name.java
>
>          Time Spent: 2h
>  Remaining Estimate: 0h
>
> It not possible to use Embedded attribute in Criteria API. E.g. having the following entity
> @Entity
> class Client {
> 	@Embedded
> 	private Name name;
> }
> @Embeddable
> public class Name implements Serializable {
>   @Basic
>     private String firstName;
>   @Basic
>     private String lastName;
> }
> The following throws an exception
> CriteriaBuilder cb = em.getCriteriaBuilder();
> CriteriaQuery<ClientCard> cq = cb.createQuery(Client.class);
> Root<ClientCard> root = cq.from(ClientCard.class);
> cq.where(cb.equal(root.get(Client_.name).get(Name_.firstName)), "blah");
> em.createQuery(cq).getResultList();
> Saying that Name is not managed entity:
> Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.phorest.memento.server.domain.Name
> 	at org.hibernate.ejb.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:171)
> 	at org.hibernate.ejb.criteria.JoinImpl.<init>(JoinImpl.java:54)
> 	at org.hibernate.ejb.criteria.FromImpl.constructJoin(FromImpl.java:193)
> 	at org.hibernate.ejb.criteria.FromImpl.join(FromImpl.java:176)
> 	at org.hibernate.ejb.criteria.FromImpl.join(FromImpl.java:169)
> 	at org.hibernate.ejb.criteria.FromImpl.get(FromImpl.java:559)

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