| Summary: | Trying to perform a find operation using the EntityManager and an IdClass containing only one attribute, if this attribute is null, find() operation will fail with a QueryException. | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Mauren Berti <mauren.berti> |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | CLOSED WORKSFORME | QA Contact: | |
| Severity: | normal | ||
| Priority: | P2 | CC: | andrei.ilitchev, henrique, mauren.berti, tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
|
Description
Mauren Berti
What is the expected behavior? A better error message? (In reply to comment #1) > What is the expected behavior? A better error message? Actually, it didn't happen with older versions (2.0.2) of EclipseLink. Instead, the query would simply return a null result, like it does when the IdClass has multiple fields and they're all set to null. Thereby, I think the correct behavior of EntityManager.find() using an instance of an IdClass containing a single field set to null would be a null result instead of throwing an exception, just like it does when I use an IdClass containing multiple fields, all of them set to null. 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. Will this issue be fixed? Targetting for 2.3.3 It's not a bug.
By default, if the primary key is mapped to a single field Eclipselink internally uses the "wrapped" value as a primary key - so from IdClass(null) entity manager's find method extracts null - and that's what causing the exception.
User can switch unwrapping of a single field primary key off by explicitly specifying primary key's cache type:
@PrimaryKey(cacheKeyType=CacheKeyType.CACHE_ID)
public class Employee implements java.io.Serializable {...
That would cause find IdClass(null) to return null.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |