Fix JdbcParameterBinding with RevisionType enum

This commit is contained in:
Chris Cranford 2021-03-09 17:18:06 -05:00 committed by Christian Beikov
parent 87a40f6c2f
commit 2cf8131f6e
2 changed files with 8 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.envers.RevisionType;
import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration;
import org.hibernate.envers.configuration.internal.GlobalConfiguration;
import org.hibernate.envers.internal.entities.RevisionTypeType;
import org.hibernate.envers.internal.entities.mapper.id.IdMapper;
import org.hibernate.envers.internal.entities.mapper.id.QueryParameterData;
import org.hibernate.envers.internal.entities.mapper.relation.MiddleIdData;
@ -21,6 +22,7 @@ import org.hibernate.envers.internal.tools.query.Parameters;
import org.hibernate.envers.internal.tools.query.QueryBuilder;
import org.hibernate.envers.strategy.AuditStrategy;
import org.hibernate.query.Query;
import org.hibernate.type.CustomType;
import static org.hibernate.envers.internal.entities.mapper.relation.query.QueryConstants.DEL_REVISION_TYPE_PARAMETER;
import static org.hibernate.envers.internal.entities.mapper.relation.query.QueryConstants.REVISION_PARAMETER;
@ -65,7 +67,11 @@ public abstract class AbstractRelationQueryGenerator implements RelationQueryGen
final String queryString = getQueryString( session.getFactory(), removed );
final Query query = session.createQuery( queryString );
query.setParameter( DEL_REVISION_TYPE_PARAMETER, RevisionType.DEL );
query.setParameter(
DEL_REVISION_TYPE_PARAMETER,
RevisionType.DEL,
new CustomType( new RevisionTypeType(), session.getFactory().getTypeConfiguration() )
);
query.setParameter( REVISION_PARAMETER, revision );
final IdMapper prefixIdMapper = referencingIdData.getPrefixedMapper();

View File

@ -133,7 +133,7 @@ public final class OneAuditEntityQueryGenerator extends AbstractRelationQueryGen
true
);
// e.revision_type != DEL
rootParameters.addWhereWithNamedParam( getRevisionTypePath(), false, "!=", DEL_REVISION_TYPE_PARAMETER );
rootParameters.addWhereWithNamedParam( getRevisionTypePath(), true, "!=", DEL_REVISION_TYPE_PARAMETER );
}
@Override