[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4787?page=c...
]
Eric Citaire commented on HHH-4787:
-----------------------------------
I found a workaround :
{noformat}
class IsNullCriterion implements AuditCriterion {
private String propertyName;
public IsNullCriterion(String propertyName) {
this.propertyName = propertyName;
}
public void addToQuery(AuditConfiguration auditCfg,
String entityName, QueryBuilder qb,
Parameters parameters) {
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(auditCfg, entityName,
propertyName);
if (relatedEntity == null) {
parameters.addWhere(propertyName, true, " is ", "null", false);
} else {
List<QueryParameterData> parametersData =
relatedEntity.getIdMapper().mapToQueryParametersFromId(null);
for (QueryParameterData parameterData : parametersData) {
parameters.addWhere(parameterData.getQueryParameterName(), true, " is ",
"null", false);
}
}
}
}
{noformat}
you can use it by replacing this :
{noformat}
.add(AuditEntity.property("str1").isNotNull())
{noformat}
by this :
{noformat}
.add(new IsNullCriterion("str1"))
{noformat}
AuditProperty.isNull() doesn't generate "tab.col is
null" SQL clause as expected
--------------------------------------------------------------------------------
Key: HHH-4787
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4787
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.3.0.GA
Environment: Hibernate 3.3.0.GA, Envers 1.2.2, HSQLDB Database
Reporter: Eric Citaire
Priority: Critical
AuditProperty.isNull() generate a SQL condition like this :
"tab.col=?"
where the bind variable is mapped to a null value.
This doesn't work : most database engines will return false in every case.
It should use the "is null" test instead :
"tab.col is null"
http://en.wikipedia.org/wiki/SQL#Null_and_Three-Valued_Logic_.283VL.29
--
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