[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1334?page=c...
]
John Newman commented on HHH-1334:
----------------------------------
Hi,
I also have this requirement,
for (int i = 0; i < queryArgs.lengh; ++i) {
if (Collection.class.isAssignableFrom(queryArgs[i].getClass()) {
query.setParameterList(i, (Collection) queryArgs[i]); // would work but this
method doesn't exist for reason above
} else {
query.setParameter(i, queryArgs[i]);
}
}
now since we won't be seeing that method, I could do:
String[] paramNames = query.getParameterNames();
for (int i = 0; i < queryArgs.lengh; ++i) {
if (Collection.class.isAssignableFrom(queryArgs[i].getClass()) {
query.setParameterList(parameterNames[i], (Collection) queryArgs[i]); // would
work but the param names are not in the correct order.
} else {
query.setParameter(i, queryArgs[i]);
}
}
so I figure typically when you have something in a map that is out of order, you can just
use a LinkedHashMap to keep the order straight. Looking around here, (god hibernate is
complicated) I found what I think to be the source, line 290 of HQLQueryPlan:
Map namedParamDescriptorMap = new HashMap();
Just taking a stab at it I wonder if switching that to LinkedHashMap would do the trick?
If those params can come out in the order they appear in the query, setParameterList(i, o)
should be possible.
But I don't think that would cover the case of mixed named & ordinal params :
query="FROM X where y = ? and z = ? and list = :list and q = ? ...
thoughts?
Implements query.setParameterList(int position, Collection vals)
----------------------------------------------------------------
Key: HHH-1334
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1334
Project: Hibernate3
Issue Type: Improvement
Components: core
Affects Versions: 3.1
Reporter: Emmanuel Bernard
This is expected by EJB3
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira