HHH-3575: fix with test
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15463 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
6a7db82fe0
commit
c1312db934
|
@ -48,8 +48,12 @@ public class AuditConjunction implements AuditCriterion, ExtendableCriterion {
|
|||
public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
|
||||
Parameters andParameters = parameters.addSubParameters(Parameters.AND);
|
||||
|
||||
for (AuditCriterion criterion : criterions) {
|
||||
criterion.addToQuery(verCfg, entityName, qb, andParameters);
|
||||
if (criterions.size() == 0) {
|
||||
andParameters.addWhere("1", false, "=", "1", false);
|
||||
} else {
|
||||
for (AuditCriterion criterion : criterions) {
|
||||
criterion.addToQuery(verCfg, entityName, qb, andParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,12 @@ public class AuditDisjunction implements AuditCriterion, ExtendableCriterion {
|
|||
public void addToQuery(AuditConfiguration verCfg, String entityName, QueryBuilder qb, Parameters parameters) {
|
||||
Parameters orParameters = parameters.addSubParameters(Parameters.OR);
|
||||
|
||||
for (AuditCriterion criterion : criterions) {
|
||||
criterion.addToQuery(verCfg, entityName, qb, orParameters);
|
||||
if (criterions.size() == 0) {
|
||||
orParameters.addWhere("0", false, "=", "1", false);
|
||||
} else {
|
||||
for (AuditCriterion criterion : criterions) {
|
||||
criterion.addToQuery(verCfg, entityName, qb, orParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -84,6 +84,8 @@ public abstract class AbstractVersionsQuery implements AuditQuery {
|
|||
|
||||
qb.build(querySb, queryParamValues);
|
||||
|
||||
System.out.println("QUERY: " + querySb.toString());
|
||||
|
||||
Query query = versionsReader.getSession().createQuery(querySb.toString());
|
||||
for (Map.Entry<String, Object> paramValue : queryParamValues.entrySet()) {
|
||||
query.setParameter(paramValue.getKey(), paramValue.getValue());
|
||||
|
|
|
@ -240,4 +240,33 @@ public class SimpleQuery extends AbstractEntityTest {
|
|||
assert result.get(1).equals(RevisionType.MOD);
|
||||
assert result.get(2).equals(RevisionType.DEL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyRevisionOfEntityQuery() {
|
||||
List result = getVersionsReader().createQuery()
|
||||
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
|
||||
.getResultList();
|
||||
|
||||
assert result.size() == 7;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyConjunctionRevisionOfEntityQuery() {
|
||||
List result = getVersionsReader().createQuery()
|
||||
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
|
||||
.add(AuditRestrictions.conjunction())
|
||||
.getResultList();
|
||||
|
||||
assert result.size() == 7;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyDisjunctionRevisionOfEntityQuery() {
|
||||
List result = getVersionsReader().createQuery()
|
||||
.forRevisionsOfEntity(StrIntTestEntity.class, false, true)
|
||||
.add(AuditRestrictions.disjunction())
|
||||
.getResultList();
|
||||
|
||||
assert result.size() == 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue