[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5938) Entities with compound primary keys are not properly handled when querying metamodel and using Criteria API
Jaroslaw Lewandowski (JIRA)
noreply at atlassian.com
Fri Feb 18 06:38:05 EST 2011
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
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.
-
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