Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 329089 - PERF: EJBQueryImpl.setParamenterInternal() move indexOf check inside non-native block
Summary: PERF: EJBQueryImpl.setParamenterInternal() move indexOf check inside non-nati...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Nobody - feel free to take it CLA
QA Contact:
URL: https://fisheye2.atlassian.com/change...
Whiteboard:
Keywords:
Depends on:
Blocks: 325167
  Show dependency tree
 
Reported: 2010-10-29 14:33 EDT by Michael OBrien CLA
Modified: 2022-06-09 10:19 EDT (History)
2 users (show)

See Also:


Attachments
329989 Performance fix for EJBQueryImpl.setParameterInternal() (1.00 KB, patch)
2010-10-29 14:38 EDT, Michael OBrien CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael OBrien CLA 2010-10-29 14:33:57 EDT
>int index = query.getArguments().indexOf(name);
>should be moved to a smaller scope in
    protected void setParameterInternal(String name, Object value, boolean isIndex) {
        DatabaseQuery query = getDatabaseQueryInternal();
>        int index = query.getArguments().indexOf(name);
        if (query.getQueryMechanism().isJPQLCallQueryMechanism()) { // only non native queries
            if (index == -1) {
                if (isIndex) {
                    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-index", new Object[] { name, query.getEJBQLString() }));
                } else {
                    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-name", new Object[] { name, query.getEJBQLString() }));
                }
            }
            Class type = query.getArgumentTypes().get(index);
            if (!isValidActualParameter(value, type)) {
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] { name, value.getClass(), query.getArgumentTypes().get(index), query.getEJBQLString() }));
            }
        }
        this.parameterValues.put(name, value);
    }

>should be
    protected void setParameterInternal(String name, Object value, boolean isIndex) {
        DatabaseQuery query = getDatabaseQueryInternal();
        if (query.getQueryMechanism().isJPQLCallQueryMechanism()) { // only non native queries
>            int index = query.getArguments().indexOf(name);
            if (index == -1) {
                if (isIndex) {
                    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-index", new Object[] { name, query.getEJBQLString() }));
                } else {
                    throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-wrong-argument-name", new Object[] { name, query.getEJBQLString() }));
                }
            }
            Class type = query.getArgumentTypes().get(index);
            if (!isValidActualParameter(value, type)) {
                throw new IllegalArgumentException(ExceptionLocalization.buildMessage("ejb30-incorrect-parameter-type", new Object[] { name, value.getClass(), query.getArgumentTypes().get(index), query.getEJBQLString() }));
            }
        }
        this.parameterValues.put(name, value);
    }
Comment 1 Michael OBrien CLA 2010-10-29 14:38:04 EDT
Created attachment 182073 [details]
329989 Performance fix for EJBQueryImpl.setParameterInternal()
Comment 2 Michael OBrien CLA 2010-11-12 11:48:38 EST
>scope reduction in SVN TXN # 8494
https://fisheye2.atlassian.com/changelog/eclipselink/?cs=8494
Comment 3 Eclipse Webmaster CLA 2022-06-09 10:19:29 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink