[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5051) JPA 2 Criteria Query with Object as Parameter not Working
Gail Badner (JIRA)
noreply at atlassian.com
Mon Apr 5 13:27:31 EDT 2010
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=36144#action_36144 ]
Gail Badner commented on HHH-5051:
----------------------------------
Hi Guido,
This may have been fixed by changes for HHH-2088, which is in 3.5.0-Final. Can you give that version a try and let us know if it's fixed?
Thanks,
Gail
> JPA 2 Criteria Query with Object as Parameter not Working
> ---------------------------------------------------------
>
> Key: HHH-5051
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5051
> Project: Hibernate Core
> Issue Type: Bug
> Components: entity-manager
> Affects Versions: 3.5.0-CR-2
> Reporter: Guido Müller
> Priority: Blocker
>
> The problem is with this scenario:
> 2 Entity classes A and B
> We have a 1:N relation between A (N) and B (1)
> This test fails:
> I get one instance of B with the entity manager find method.
> I query the database with JPA 2 query to get a list of all instances of A that have the many-to-one property equals the instance got from the 1st step.
> Code:
> EntityManager em = ...
> B b = em.find(B.class, 1L);
> CriteriaBuilder cb = em.getCriteriaBuilder();
> CriteriaQuery<A> q = cb.createQuery(A.class);
> Root<A> p = q.from(A.class);
> q.select(p).where(cb.equal(p.get(A_.b), b));
> List<A> l = em.createQuery(q).getResultList();
> em.close();
> This does not work but it should. It works properly with EclipseLink. In Hibernate I get this to work when I provide b.getId() as Parameter. But this is not correct!
--
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