[hibernate-issues] [Hibernate-JIRA] Resolved: (HHH-5938) Entities with compound primary keys are not properly handled when querying metamodel and using Criteria API
Gail Badner (JIRA)
noreply at atlassian.com
Fri Sep 23 19:29:35 EDT 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Gail Badner resolved HHH-5938.
------------------------------
Resolution: Duplicate
Assignee: Gail Badner
> Entities with compound primary keys are not properly handled when querying metamodel and using Criteria API
> -----------------------------------------------------------------------------------------------------------
>
> Key: HHH-5938
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5938
> Project: Hibernate Core
> Issue Type: Bug
> Affects Versions: 3.6.0
> Reporter: Jaroslaw Lewandowski
> Assignee: Gail Badner
>
> Suppose we have entity defined like this:
> {code}
> @Entity
> class Foo {
> @Id Long first;
> @Id Long second;
> ....
> }
> {code}
> Then the following code will fail:
> {code}
> Metamodel mm = entityManager.getMetamodel();
> EntityType<Foo> foo_ = mm.entity(Foo.class);
> foo_.getSingularAttribute("first", Long.class);
> foo_.getSingularAttribute("second", Long.class);
> {code}
> The same problems exists trying to query this entity:
> {code}
> CriteriaBuilder cb = entityManager.getMetamodel();
> CriteriaQuery<Foo> cq = cb.createQuery(Foo.class);
> Root<Foo> foo = cq.from(Foo.class);
> cq.where(cb.equal(foo.get("first"), 1L), cb.equal(foo.get("second"), 2L));
> {code}
> See that attributes are accessed by name. In the first example IllegalArgumentException is thrown in second NPE
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list