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

org.hibernate.envers.boot.model.CompositeIdentifier Maven / Gradle / Ivy

There is a newer version: 7.0.0.Beta2
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.boot.model;

import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmCompositeIdType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintContainer;
import org.hibernate.envers.boot.spi.EnversMetadataBuildingContext;

/**
 * Represents an identifier based on a {@code composite-id} mapping.
 *
 * @author Chris Cranford
 */
public class CompositeIdentifier extends AbstractIdentifier {

	public CompositeIdentifier(EnversMetadataBuildingContext metadataBuildingContext) {
		super( metadataBuildingContext.getConfiguration().getOriginalIdPropertyName() );
	}

	@Override
	public JaxbHbmCompositeIdType build() {
		final JaxbHbmCompositeIdType identifier = new JaxbHbmCompositeIdType();
		identifier.setName( getName() );

		// For all mapped attributes, add them to the list of key properties
		for ( Attribute attribute : getAttributes() ) {
			identifier.getKeyPropertyOrKeyManyToOne().add( (JaxbHbmToolingHintContainer) attribute.build() );
		}

		return identifier;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy