After an upgrade from 3.0-b2 to 3.0-b3 one of my apps with a
Criteria.Criterion.setIgnoreCase() method call started throwing
null pointer exceptions. I think there may be a bug with the
way ignore case works in b3. Unfortunately, I haven't had a
chance to try b4.
Here is a simple class that illustrates the problem:
import org.apache.torque.util.Criteria;
public class CriterionTest {
public static void main(String args[]) {
Criteria myCriteria = new Criteria();
Criteria.Criterion myCriterion =
myCriteria.getNewCriterion(
"the_col", (Object)"foobar", Criteria.LIKE);
System.err.println("before setIgnoreCase: " + myCriterion);
myCriterion.setIgnoreCase(true);
System.err.println("after setIgnoreCase: " + myCriterion);
}
}
java CriterionTest
(util.Criteria 3306) Could not get a DB adapter, so sql may be
wrong
before setIgnoreCase: .the_col = 'foobar'
(util.Criteria 3306) Could not get a DB adapter, so sql may be
wrong
Exception in thread "main" java.lang.NullPointerException
at org.apache.torque.util.SqlExpression.buildLike(SqlExpression.java:396)
at org.apache.torque.util.SqlExpression.build(SqlExpression.java:298)
at org.apache.torque.util.Criteria$Criterion.appendTo(Criteria.java:3432)
at org.apache.torque.util.Criteria$Criterion.toString(Criteria.java:3573)
at java.lang.String.valueOf(String.java:2173)
at java.lang.StringBuffer.append(StringBuffer.java:369)
at CriterionTest.main(CriterionTest.java:15)
(Sorry about the long lines.)
Before the setIgnoreCase(true) Criteria.Criterion.toString() works
as expected. After the call it throws an exception. A similar
test with Criteria seemed to work properly; no NPE.
For lack of time, I have disabled case-insensitivity in my code.
If I get a chance (sadly unlikely) I will track down the bug and
attempt to submit a patch.
I searched turbine-torque-user and turbine-torque-dev archives
and didn't see any mention of this bug. My apologies for wasting
everyone's time if it is already fixed in b4.
Thanks to all the developers working on torque. Using it has
saved me significant development time on my last project.
--Brad
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>