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

org.hibernate.envers.query.criteria.AuditId Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha3
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.criteria;

import org.hibernate.envers.query.criteria.internal.IdentifierEqAuditExpression;
import org.hibernate.envers.query.internal.property.EntityPropertyName;
import org.hibernate.envers.query.internal.property.PropertyNameGetter;

/**
 * Create restrictions and projections for the id of an audited entity.
 *
 * @author Adam Warski (adam at warski dot org)
 * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
 */
@SuppressWarnings({"JavaDoc"})
public class AuditId extends AuditProperty {
	public static final String IDENTIFIER_PLACEHOLDER = "$$id$$";
	private static final PropertyNameGetter IDENTIFIER_PROPERTY_GETTER = new EntityPropertyName( IDENTIFIER_PLACEHOLDER );

	private final String alias;

	public AuditId(String alias) {
		super( alias, IDENTIFIER_PROPERTY_GETTER );
		this.alias = alias;
	}

	/**
	 * Apply an "equal" constraint
	 */
	@Override
	public AuditCriterion eq(Object id) {
		return new IdentifierEqAuditExpression( alias, id, true );
	}

	/**
	 * Apply a "not equal" constraint
	 */
	@Override
	public AuditCriterion ne(Object id) {
		return new IdentifierEqAuditExpression( alias, id, false );
	}

	// Projections

	@Override
	public AuditCriterion hasChanged() {
		throw new UnsupportedOperationException();
	}

	@Override
	public AuditCriterion hasNotChanged() {
		throw new UnsupportedOperationException();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy