org.hibernate.boot.model.source.internal.hbm.IdentifierSourceSimpleImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
Hibernate's core ORM functionality
/*
* 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;
}
}