Message:
The following issue has been closed.
Resolver: Gavin King
Date: Thu, 4 Dec 2003 1:17 AM
Well, I made it at least generate something sensible like "foo in ()". It turns out that most SQL dialects don't actually support this syntax - but thats ok, I think.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-517
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-517
Summary: Expression.in(String, Collection) doesn't check Collection.size()==0 automatically
Type: Bug
Status: Closed
Priority: Major
Resolution: FIXED
Project: Hibernate2
Fix Fors:
2.1 final
Versions:
2.1 rc1
Assignee: Gavin King
Reporter: fafnirchen
Created: Thu, 4 Dec 2003 12:56 AM
Updated: Thu, 4 Dec 2003 1:17 AM
Environment: w2k, jdk1.4
Description:
I used Expression.in(column:String, inValue:Collection) to add query condition. As for argument Collection it is a dnynamic List. When inValue.size()==0 I do not want Expression add condition string like xxxColumn in (?).Now when inValue.size()==0 Hibernate2 throws Exception when Criteria.list().
The fragment of my code is the following.
Criteria crit = session.createCriteria(WsStockPriceModel.class);
crit.add(
Expression.between(
"pubDate",
model.getSearchBeginDate(),
model.getSearchEndDate()));
crit.add(Expression.in("productName",
model.getSearchProductNames()));
crit.setFirstResult(firstResult);
crit.setMaxResults(pageSize);
List list = crit.list();
And the fragment of Exception is the following.
java.lang.NegativeArraySizeException
at java.lang.StringBuffer.<init>(StringBuffer.java:115)
at net.sf.hibernate.util.StringHelper.repeat(StringHelper.java:47)
at net.sf.hibernate.expression.InExpression.toSqlString(InExpression.java:26)
at net.sf.hibernate.loader.CriteriaLoader.<init>(CriteriaLoader.java:61)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:3430)
at net.sf.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:177)
...............................
---------------------------------------------------------------------
JIRA INFORMATION:
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.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|