Buggy code:
public void nontransactionalAll ( Collection objs ) { } public void nontransactionalAll ( Object [ ] objs ) { } public Generator getNamedGenerator ( String name ) { } public Generator getIdGenerator ( Class forClass ) { } public Generator getFieldGenerator ( Class forClass , String fieldName ) { } public < T > Extent < T > createExtent ( Class < T > cls , boolean subclasses ) { } public < T > TypedQuery < T > createQuery ( String query , Class < T > resultClass ) { } public OpenJPAQuery createQuery ( String query ) { } public OpenJPAQuery createQuery ( String language , String query ) { } public OpenJPAQuery createQuery ( Query query ) { } public < T > TypedQuery < T > createNamedQuery ( String name , Class < T > resultClass ) { } public OpenJPAQuery createNamedQuery ( String name ) { } public OpenJPAQuery createNativeQuery ( String query ) { } public OpenJPAQuery createNativeQuery ( String query , Class cls ) { } public OpenJPAQuery createNativeQuery ( String query , String mappingName ) { } private static void validateSQL ( String query ) { } PreparedQueryCache getPreparedQueryCache ( ) { } PreparedQuery getPreparedQuery ( String id ) { } public void setFlushMode ( FlushModeType flushMode ) { } public FlushModeType getFlushMode ( ) { } static FlushModeType fromFlushBeforeQueries ( int flush ) { } static int toFlushBeforeQueries ( FlushModeType flushMode ) { } public void clear ( ) { } public Object getDelegate ( ) { } public LockModeType getLockMode ( Object entity ) { } public void lock ( Object entity , LockModeType mode ) { } public void lock ( Object entity ) { } public void lock ( Object entity , LockModeType mode , int timeout ) { } public void lock ( Object entity , LockModeType mode , Map < String , Object > properties ) { } public void lockAll ( Collection entities ) { } public void lockAll ( Collection entities , LockModeType mode , int timeout ) { } public void lockAll ( Object ... entities ) { } public void lockAll ( Object [ ] entities , LockModeType mode , int timeout ) { } public boolean cancelAll ( ) { } public Object getConnection ( ) { } public Collection getManagedObjects ( ) { } public Collection getTransactionalObjects ( ) { } public Collection getPendingTransactionalObjects ( ) { } public Collection getDirtyObjects ( ) { } public boolean getOrderDirtyObjects ( ) { } public void setOrderDirtyObjects ( boolean order ) { } public void dirtyClass ( Class cls ) { } @ SuppressWarnings ( "unchecked" ) public Collection < Class > getPersistedClasses ( ) { } @ SuppressWarnings ( "unchecked" ) public Collection < Class > getUpdatedClasses ( ) { } @ SuppressWarnings ( "unchecked" ) public Collection < Class > getRemovedClasses ( ) { } public < T > T createInstance ( Class < T > cls ) { } public void close ( ) { } public boolean isOpen ( ) { } public void dirty ( Object o , String field ) { } public Object getObjectId ( Object o ) { } public boolean isDirty ( Object o ) { } public boolean isTransactional ( Object o ) { } public boolean isPersistent ( Object o ) { } public boolean isNewlyPersistent ( Object o ) { } public boolean isRemoved ( Object o ) { } public boolean isDetached ( Object entity ) { } public Object getVersion ( Object o ) { } void assertNotCloseInvoked ( ) { } void assertValidAttchedEntity ( Object entity ) { } public Object processArgument ( Object arg ) { } public Object processReturn ( Object oid , OpenJPAStateManager sm ) { } public int processArgument ( int op , Object obj , OpenJPAStateManager sm ) { } public int hashCode ( ) { } public boolean equals ( Object other ) { } public void readExternal ( ObjectInput in ) throws IOException , ClassNotFoundException { } public void writeExternal ( ObjectOutput out ) throws IOException { } private static class BrokerBytesInputStream extends ObjectInputStream { private OpenJPAConfiguration conf ; BrokerBytesInputStream ( byte [ ] bytes , OpenJPAConfiguration conf ) throws IOException { } private Class primitiveType ( char type ) { } protected Class resolveClass ( ObjectStreamClass classDesc ) throws IOException , ClassNotFoundException { } private Class lookupClass ( String className ) throws ClassNotFoundException { } } public void detach ( Object entity ) { } public < T > TypedQuery < T > createQuery ( CriteriaQuery < T > criteriaQuery ) { org . apache . openjpa . kernel . Query kernelQuery = _broker . newQuery ( LANG_CRITERIA , criteriaQuery ) ; kernelQuery . compile ( ) ; QueryImpl < T > facadeQuery = new QueryImpl < T > ( this , _ret , kernelQuery ) ; Set < ParameterExpression < ? > > params = ( ( CriteriaQueryImpl < T > ) ( criteriaQuery ) ) . getParameters ( ) ; for ( ParameterExpression < ? > param : params ) { <START_BUG> facadeQuery . registerParameter ( ( ( QueryParameter < ? > ) ( param ) ) ) ; <END_BUG> } return facadeQuery ; } public OpenJPAQuery createDynamicQuery ( QueryDefinition qdef ) { } public Map < String , Object > getProperties ( ) { } public CriteriaBuilder getQueryBuilder ( ) { } public Set < String > getSupportedProperties ( ) { } public < T > T unwrap ( Class < T > cls ) { } public void setQuerySQLCache ( boolean flag ) { } public boolean getQuerySQLCache ( ) { } RuntimeExceptionTranslator getExceptionTranslator ( ) { } private void processLockProperties ( FetchPlan fPlan , LockModeType mode , Map < String , Object > properties ) { } public Metamodel getMetamodel ( ) { } public void setProperty ( String arg0 , Object arg1 ) { } }

Fix:
facadeQuery . declareParameter ( param , param ) ;