[ http://issues.apache.org/jira/browse/TORQUE-59?page=all ]
Thomas Vandahl closed TORQUE-59. -------------------------------- > correctBooleans() overwrites complex boolean criteria > ----------------------------------------------------- > > Key: TORQUE-59 > URL: http://issues.apache.org/jira/browse/TORQUE-59 > Project: Torque > Issue Type: Bug > Components: Runtime > Affects Versions: 3.2 > Environment: MySQL 5 > Reporter: Thoralf Rickert > Assigned To: Thomas Fischer > Fix For: 3.3 > > > If you have a table with a nullable boolean column: > <column name="test" type="booleanint" size="1"/> > and create a criteria like this: > Criterion c1 = criteria.getNewCriterion(TEST, false, Criteria.EQUAL); > Criterion c2 = criteria.getNewCriterion(TEST, null, Criteria.ISNULL); > criteria.add(c1.or(c2)); > then the createQueryString returns the correct toString() result with > ...WHERE (TEST = 0 or TEST IS NULL) ... > but when you call doSelect(), it sends just TEST = 0 to the database. > The problem is in the generated correctBooleans(Criteria) method. It checks > if the Criteria contains one of the boolean column and replaces the criterion > with an int value. So, in the above situation it removes the Criteria.ISNULL > part...that is not expected. > ..... > if (criteria.containsKey(TEST)) > { > Object possibleBoolean = criteria.get(TEST); > if (possibleBoolean instanceof Boolean) > { > criteria.add(TEST, ((Boolean) possibleBoolean).booleanValue() > ? 1 : 0); > } > } > The only possible workaround is to use the integer value (0,1) in the > criterion (Criterion c1 = criteria.getNewCriterion(TEST, 0, Criteria.EQUAL) > ). But this is not expected, because it is database specific. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]