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

Jaroslaw Lewandowski (JIRA) noreply at atlassian.com
Tue Nov 17 10:35:08 EST 2009


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: query-criteria
    Affects Versions: 3.5.0-Beta-2
            Reporter: Jaroslaw Lewandowski


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