Community
Participate
Working Groups
Build Identifier: 20110615-0604 Error: javax.faces.FacesException: javax.ejb.EJBException: Exception [EclipseLink-6094] (Eclipse Persistence Services - 2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.QueryException Exception Description: The parameter name [EMPLOYEE_ID] in the query's selection criteria does not match any parameter name defined in the query. Query: ReadObjectQuery(name="readObject" referenceClass=TEmployees sql="SELECT EMPLOYEE_ID, EMPLOYEE_NAME FROM T_EMPLOYEES WHERE (EMPLOYEE_ID = ?)") I noticed the problem occurs ONLY when the IdClass has only one attribute AND it is null. It does not occur when a multiple field IdClass with all fields set to null is provided to the EntityManager.find() method. I believe this behavior is erroneous, since with earlier EclipseLink versions it did not occur, and with a multiple fields IdClass it also does not occur. Reproducible: Always Steps to Reproduce: 1. Create an IdClass containing only one attribute, for an existing database table. 2. Instantiate this IdClass. Don't set any of the attributes of this instance, leaving them null. 3. Perform a EntityManager.find() operation providing this IdClass.
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