use of org.hibernate.envers.internal.entities.mapper.id.QueryParameterData in project hibernate-orm by hibernate.
the class RelatedAuditInExpression method addToQuery.
@Override
protected void addToQuery(EnversService enversService, AuditReaderImplementor versionsReader, String entityName, String alias, QueryBuilder qb, Parameters parameters) {
String propertyName = CriteriaTools.determinePropertyName(enversService, versionsReader, entityName, propertyNameGetter);
RelationDescription relatedEntity = CriteriaTools.getRelatedEntity(enversService, entityName, propertyName);
if (relatedEntity == null) {
throw new AuditException("The criterion can only be used on a property that is a relation to another property.");
}
// todo: should this throw an error if qpdList is null? is it possible?
List<QueryParameterData> qpdList = relatedEntity.getIdMapper().mapToQueryParametersFromId(propertyName);
if (qpdList != null) {
QueryParameterData qpd = qpdList.iterator().next();
parameters.addWhereWithParams(alias, qpd.getQueryParameterName(), "in (", ids, ")");
}
}
use of org.hibernate.envers.internal.entities.mapper.id.QueryParameterData in project hibernate-orm by hibernate.
the class AbstractRelationQueryGenerator method getQuery.
@Override
public Query getQuery(AuditReaderImplementor versionsReader, Object primaryKey, Number revision, boolean removed) {
final Query query = versionsReader.getSession().createQuery(removed ? getQueryRemovedString() : getQueryString());
query.setParameter(DEL_REVISION_TYPE_PARAMETER, RevisionType.DEL);
query.setParameter(REVISION_PARAMETER, revision);
for (QueryParameterData paramData : referencingIdData.getPrefixedMapper().mapToQueryParametersFromId(primaryKey)) {
paramData.setParameterValue(query);
}
return query;
}
Aggregations