Community
Participate
Working Groups
>The case is wrong in the following example >The code as written will insert [NULL] as a value for the firstname named parameter http://wiki.eclipse.org/Using_EclipseLink_JPA_Extensions_(ELUG)#Using_Named_Parameters_in_a_Native_Query >following Query queryEmployees = entityManager.createNativeQuery( "SELECT * FROM EMPLOYEE emp WHERE emp.fname LIKE #firstname"); queryEmployees.setParameter("firstName", "Joan"); Collection employees = queryEmployees.getResultList(); >should be Query queryEmployees = entityManager.createNativeQuery( "SELECT * FROM EMPLOYEE emp WHERE emp.fname LIKE #firstname"); queryEmployees.setParameter("firstname", "Joan"); Collection employees = queryEmployees.getResultList(); >non-trivial as the wiki documentation needs to be modified to either set the correct capitalization >or set the upper case flag [useUpperCaseForComparisions] on the parameter >The following bind parameter call will fail when the cases do not match for aQuery = entityManager.createNativeQuery("select * from table where id = #anid...."); aQuery.setParameter("anId", 32); // force use of "anId" instead of "anid" to test case-sensitivity >in the following [value] will be null DatasourceCall.translateQueryString():739 Object value = getValueForInParameter(parameter, translationRow, modifyRow, session, false); org.eclipse.persistence.example.dataparallel.GridClient at localhost:52520 Thread [Main Thread] (Suspended) SQLCall(DatasourceCall).translateQueryString(AbstractRecord, AbstractRecord, AbstractSession) line: 739 SQLCall(DatabaseCall).translate(AbstractRecord, AbstractRecord, AbstractSession) line: 985 CallQueryMechanism(DatasourceCallQueryMechanism).executeCall(DatasourceCall) line: 205 CallQueryMechanism(DatasourceCallQueryMechanism).executeCall() line: 192 CallQueryMechanism(DatasourceCallQueryMechanism).executeNoSelectCall() line: 235 CallQueryMechanism(DatasourceCallQueryMechanism).executeNoSelect() line: 215 DataModifyQuery.executeDatabaseQuery() line: 85 DataModifyQuery(DatabaseQuery).execute(AbstractSession, AbstractRecord) line: 782 DataModifyQuery(DatabaseQuery).executeInUnitOfWork(UnitOfWorkImpl, AbstractRecord) line: 685 RepeatableWriteUnitOfWork(UnitOfWorkImpl).internalExecuteQuery(DatabaseQuery, AbstractRecord) line: 2960 RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, AbstractRecord, int) line: 1303 RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, AbstractRecord) line: 1285 RepeatableWriteUnitOfWork(AbstractSession).executeQuery(DatabaseQuery, List) line: 1259 EJBQueryImpl<X>.executeUpdate() line: 534 GridClient.nativeQuery() line: 119 GridClient.main(String[]) line: 353 >The case must be the same for both the named SQL query parameter name and the setParameter("name", value) call >this works aQuery.setParameter("anid", 32); >trace parameter DatabaseField (id=155) name "anid" (id=154) nameForComparisons null qualifiedName "anid" (id=154) useUpperCaseForComparisons false value Integer (id=106) value 32
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink