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

org.hibernate.boot.model.source.internal.hbm.IdentifierSourceSimpleImpl 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.boot.model.source.internal.hbm;

import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.model.source.spi.IdentifierSourceSimple;
import org.hibernate.boot.model.source.spi.SingularAttributeSource;
import org.hibernate.boot.model.source.spi.ToolingHintContext;
import org.hibernate.id.EntityIdentifierNature;

/**
 * Models a simple {@code } mapping
 *
 * @author Steve Ebersole
 */
class IdentifierSourceSimpleImpl implements IdentifierSourceSimple {
	private final SingularIdentifierAttributeSourceImpl attribute;
	private final IdentifierGeneratorDefinition generatorDefinition;
	private final String unsavedValue;

	private final ToolingHintContext toolingHintContext;

	public IdentifierSourceSimpleImpl(RootEntitySourceImpl rootEntitySource) {
		final JaxbHbmRootEntityType jaxbEntityMapping = rootEntitySource.jaxbEntityMapping();
		this.attribute = new SingularIdentifierAttributeSourceImpl(
				rootEntitySource.sourceMappingDocument(),
				rootEntitySource,
				jaxbEntityMapping.getId()
		);
		this.generatorDefinition = EntityHierarchySourceImpl.interpretGeneratorDefinition(
				rootEntitySource.sourceMappingDocument(),
				rootEntitySource.getEntityNamingSource(),
				rootEntitySource.jaxbEntityMapping().getId().getGenerator()
		);
		this.unsavedValue = jaxbEntityMapping.getId().getUnsavedValue();

		this.toolingHintContext = Helper.collectToolingHints(
				rootEntitySource.getToolingHintContext(),
				jaxbEntityMapping.getId()
		);
	}

	@Override
	public SingularAttributeSource getIdentifierAttributeSource() {
		return attribute;
	}

	@Override
	public IdentifierGeneratorDefinition getIdentifierGeneratorDescriptor() {
		return generatorDefinition;
	}

	@Override
	public EntityIdentifierNature getNature() {
		return EntityIdentifierNature.SIMPLE;
	}

	@Override
	public String getUnsavedValue() {
		return unsavedValue;
	}

	@Override
	public ToolingHintContext getToolingHintContext() {
		return toolingHintContext;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy