| Summary: | query on isNull(many-to-one mapped attribute) does not work | ||||||
|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Björn Clemens <bjoern.clemens> | ||||
| Component: | Eclipselink | Assignee: | Project Inbox <eclipselink.orm-inbox> | ||||
| Status: | NEW --- | QA Contact: | |||||
| Severity: | major | ||||||
| Priority: | P2 | CC: | pbloigu, tom.ware | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | All | ||||||
| OS: | All | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Please post examples of the mappings. Created attachment 196569 [details]
testcase as maven project to reproduce the bug
added testcase (simple mapping without mapping table ) that reproduces the bug
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next. I would like to see this fixed as this is a) quite fundamental and b) subtle. As a workaround one can use an explicit left join, though, and then call isNull and provide the join as the parameter. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 2.2.0.v20110202-r8913 environment: optional - many to one-relation between two tables task: select all elements on many-table what are not mapped to target table (ref_id column contains null value) the following code returns no result, even if matching values are available in table CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<AnyMappedObject> criteriaQuery = builder.createQuery(AnyMappedObject.class); Root<AnyMappedObject> entity_ = criteriaQuery.from(AnyMappedObject.class); criteriaQuery.where(entity_.get("target").isNull()); TypedQuery<AnyMappedObject> entityQuery = entityManager.createQuery(criteriaQuery); List<AnyMappedObject> results = entityQuery.getResultList(); Case 1: bidirectional mapping via join-column/inverse-join-column generated sql: SELECT t1.ID, t1.anyAttribute FROM TargetTable t0, SourceTable t1 WHERE (NOT EXISTS (SELECT t4.ID FROM TargetTable t5, SourceTable t4 WHERE (t5.targetId = t1.ID)) AND ((t0.targetId = t1.ID) AND (t0.ID = t0.ID))) expected sql: SELECT t0.anyAttribute FROM AnyMappedObjectTable t0 WHERE t0.targetId is null case 2: unidirectional mapping generated sql: SELECT t1.ID, t1.anyAttribute FROM TargetTable t0, SourceTable t1 WHERE ((t1.targetId IS NULL) AND (t0.ID = t1.targetId)) expected sql: SELECT t1.ID, t1.anyAttribute FROM SourceTable t1 WHERE t1.targetId is null Reproducible: Always Steps to Reproduce: 1.see details