All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.envers.query.projection.AuditProjection Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.envers.query.projection;

import org.hibernate.envers.boot.internal.EnversService;
import org.hibernate.envers.internal.entities.EntityInstantiator;

/**
 * @author Adam Warski (adam at warski dot org)
 */
public interface AuditProjection {
	/**
	 * @param enversService The EnversService
	 *
	 * @return the projection data
	 */
	ProjectionData getData(EnversService enversService);

	/**
	 * @param enversService the Envers service
	 * @param entityInstantiator the entity instantiator
	 * @param entityName the name of the entity for which the projection has been added
	 * @param revision the revision
	 * @param value the value to convert
	 * @return the converted value
	 */
	Object convertQueryResult(
			final EnversService enversService,
			final EntityInstantiator entityInstantiator,
			final String entityName,
			final Number revision,
			final Object value
	);

	class ProjectionData {

		private final String function;
		private final String alias;
		private final String propertyName;
		private final boolean distinct;

		public ProjectionData(String function, String alias, String propertyName, boolean distinct) {
			this.function = function;
			this.alias = alias;
			this.propertyName = propertyName;
			this.distinct = distinct;
		}

		public String getFunction() {
			return function;
		}

		public String getAlias(String baseAlias) {
			return alias == null ? baseAlias : alias;
		}

		public String getPropertyName() {
			return propertyName;
		}

		public boolean isDistinct() {
			return distinct;
		}

	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy