HHH-7088 - Implement secondary table support in new metamodel code
This commit is contained in:
parent
f76524786c
commit
8afab9f255
|
@ -66,16 +66,18 @@ import org.hibernate.metamodel.spi.source.SubclassEntitySource;
|
|||
public abstract class AbstractEntitySourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements EntitySource, Helper.InLineViewNameInferrer {
|
||||
|
||||
private final EntityElement entityElement;
|
||||
private final String className;
|
||||
private final String entityName;
|
||||
|
||||
private List<SubclassEntitySource> subclassEntitySources = new ArrayList<SubclassEntitySource>();
|
||||
|
||||
private int inLineViewCount = 0;
|
||||
|
||||
// logically final, but built during 'afterInstantiation' callback
|
||||
private List<AttributeSource> attributeSources;
|
||||
private Set<SecondaryTableSource> secondaryTableSources;
|
||||
private List<SubclassEntitySource> subclassEntitySources;
|
||||
|
||||
protected AbstractEntitySourceImpl(MappingDocument sourceMappingDocument, EntityElement entityElement) {
|
||||
super( sourceMappingDocument );
|
||||
|
@ -95,8 +97,6 @@ public abstract class AbstractEntitySourceImpl
|
|||
protected void afterInstantiation() {
|
||||
this.attributeSources = buildAttributeSources();
|
||||
this.secondaryTableSources = buildSecondaryTables();
|
||||
|
||||
this.subclassEntitySources = buildSubClassSources();
|
||||
}
|
||||
|
||||
protected List<AttributeSource> buildAttributeSources() {
|
||||
|
@ -161,6 +161,7 @@ public abstract class AbstractEntitySourceImpl
|
|||
else if ( JaxbBagElement.class.isInstance( attributeElement ) ) {
|
||||
results.add(
|
||||
new BagAttributeSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
JaxbBagElement.class.cast( attributeElement ),
|
||||
this
|
||||
)
|
||||
|
@ -172,6 +173,7 @@ public abstract class AbstractEntitySourceImpl
|
|||
else if ( JaxbSetElement.class.isInstance( attributeElement ) ) {
|
||||
results.add(
|
||||
new SetAttributeSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
JaxbSetElement.class.cast( attributeElement ),
|
||||
this
|
||||
)
|
||||
|
@ -189,11 +191,6 @@ public abstract class AbstractEntitySourceImpl
|
|||
}
|
||||
}
|
||||
|
||||
protected List<SubclassEntitySource> buildSubClassSources() {
|
||||
// todo : implement subclass processing
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private Set<SecondaryTableSource> buildSecondaryTables() {
|
||||
if ( ! JoinElementSource.class.isInstance( entityElement ) ) {
|
||||
return Collections.emptySet();
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.hibernate.metamodel.spi.binding.Caching;
|
|||
import org.hibernate.metamodel.spi.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
|
||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.spi.source.MappingException;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
|
||||
|
@ -50,6 +49,7 @@ import org.hibernate.metamodel.spi.source.TableSpecificationSource;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractPluralAttributeSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements PluralAttributeSource, Helper.InLineViewNameInferrer {
|
||||
private final PluralAttributeElement pluralAttributeElement;
|
||||
private final AttributeSourceContainer container;
|
||||
|
@ -60,12 +60,18 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
private final PluralAttributeElementSource elementSource;
|
||||
|
||||
protected AbstractPluralAttributeSourceImpl(
|
||||
MappingDocument sourceMappingDocument,
|
||||
final PluralAttributeElement pluralAttributeElement,
|
||||
AttributeSourceContainer container) {
|
||||
super( sourceMappingDocument );
|
||||
this.pluralAttributeElement = pluralAttributeElement;
|
||||
this.container = container;
|
||||
|
||||
this.keySource = new PluralAttributeKeySourceImpl( pluralAttributeElement.getKey(), container );
|
||||
this.keySource = new PluralAttributeKeySourceImpl(
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement.getKey(),
|
||||
container
|
||||
);
|
||||
this.elementSource = interpretElementType();
|
||||
|
||||
this.typeInformation = new ExplicitHibernateTypeSource() {
|
||||
|
@ -84,26 +90,28 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
private PluralAttributeElementSource interpretElementType() {
|
||||
if ( pluralAttributeElement.getElement() != null ) {
|
||||
return new BasicPluralAttributeElementSourceImpl(
|
||||
pluralAttributeElement.getElement(), container.getLocalBindingContext()
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement.getElement()
|
||||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getCompositeElement() != null ) {
|
||||
return new CompositePluralAttributeElementSourceImpl(
|
||||
pluralAttributeElement.getCompositeElement(), container.getLocalBindingContext()
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement.getCompositeElement()
|
||||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getOneToMany() != null ) {
|
||||
return new OneToManyPluralAttributeElementSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement,
|
||||
pluralAttributeElement.getOneToMany(),
|
||||
container.getLocalBindingContext()
|
||||
pluralAttributeElement.getOneToMany()
|
||||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getManyToMany() != null ) {
|
||||
return new ManyToManyPluralAttributeElementSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
pluralAttributeElement,
|
||||
pluralAttributeElement.getManyToMany(),
|
||||
container.getLocalBindingContext()
|
||||
pluralAttributeElement.getManyToMany()
|
||||
);
|
||||
}
|
||||
else if ( pluralAttributeElement.getManyToAny() != null ) {
|
||||
|
@ -126,10 +134,6 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
return container;
|
||||
}
|
||||
|
||||
protected LocalBindingContext bindingContext() {
|
||||
return container().getLocalBindingContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluralAttributeKeySource getKeySource() {
|
||||
return keySource;
|
||||
|
@ -147,7 +151,7 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
|
||||
@Override
|
||||
public TableSpecificationSource getCollectionTableSpecificationSource() {
|
||||
return Helper.createTableSource( pluralAttributeElement, this );
|
||||
return Helper.createTableSource( sourceMappingDocument(), pluralAttributeElement, this );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -302,7 +306,7 @@ public abstract class AbstractPluralAttributeSourceImpl
|
|||
lazySelection,
|
||||
pluralAttributeElement.getName()
|
||||
),
|
||||
bindingContext().getOrigin()
|
||||
origin()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,11 @@ import org.hibernate.metamodel.spi.source.PluralAttributeNature;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BagAttributeSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable {
|
||||
public BagAttributeSourceImpl(JaxbBagElement bagElement, AttributeSourceContainer container) {
|
||||
super( bagElement, container );
|
||||
public BagAttributeSourceImpl(
|
||||
MappingDocument sourceMappingDocument,
|
||||
JaxbBagElement bagElement,
|
||||
AttributeSourceContainer container) {
|
||||
super( sourceMappingDocument, bagElement, container );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,6 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbElementElement;
|
||||
import org.hibernate.metamodel.spi.source.BasicPluralAttributeElementSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||
import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
|
@ -36,14 +35,18 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicPluralAttributeElementSourceImpl implements BasicPluralAttributeElementSource {
|
||||
public class BasicPluralAttributeElementSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements BasicPluralAttributeElementSource {
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
private final ExplicitHibernateTypeSource typeSource;
|
||||
|
||||
public BasicPluralAttributeElementSourceImpl(
|
||||
final JaxbElementElement elementElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument sourceMappingDocument,
|
||||
final JaxbElementElement elementElement) {
|
||||
super( sourceMappingDocument );
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getContainingTableName() {
|
||||
|
@ -74,8 +77,7 @@ public class BasicPluralAttributeElementSourceImpl implements BasicPluralAttribu
|
|||
public List getColumnOrFormulaElements() {
|
||||
return elementElement.getColumnOrFormula();
|
||||
}
|
||||
},
|
||||
bindingContext
|
||||
}
|
||||
);
|
||||
|
||||
this.typeSource = new ExplicitHibernateTypeSource() {
|
||||
|
|
|
@ -34,7 +34,9 @@ import org.hibernate.metamodel.spi.source.ColumnSource;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class ColumnAttributeSourceImpl implements ColumnSource {
|
||||
class ColumnAttributeSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements ColumnSource {
|
||||
private final String tableName;
|
||||
private final String columnName;
|
||||
private TruthValue includedInInsert;
|
||||
|
@ -42,19 +44,22 @@ class ColumnAttributeSourceImpl implements ColumnSource {
|
|||
private TruthValue nullable;
|
||||
|
||||
ColumnAttributeSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
String tableName,
|
||||
String columnName,
|
||||
TruthValue includedInInsert,
|
||||
TruthValue includedInUpdate) {
|
||||
this( tableName, columnName, includedInInsert, includedInUpdate, TruthValue.UNKNOWN );
|
||||
this( mappingDocument, tableName, columnName, includedInInsert, includedInUpdate, TruthValue.UNKNOWN );
|
||||
}
|
||||
|
||||
ColumnAttributeSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
String tableName,
|
||||
String columnName,
|
||||
TruthValue includedInInsert,
|
||||
TruthValue includedInUpdate,
|
||||
TruthValue nullable) {
|
||||
super( mappingDocument );
|
||||
this.tableName = tableName;
|
||||
this.columnName = columnName;
|
||||
this.includedInInsert = includedInInsert;
|
||||
|
|
|
@ -32,7 +32,9 @@ import org.hibernate.metamodel.spi.source.ColumnSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class ColumnSourceImpl implements ColumnSource {
|
||||
class ColumnSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements ColumnSource {
|
||||
private final String tableName;
|
||||
private final JaxbColumnElement columnElement;
|
||||
private final TruthValue includedInInsert;
|
||||
|
@ -40,19 +42,22 @@ class ColumnSourceImpl implements ColumnSource {
|
|||
private final TruthValue nullable;
|
||||
|
||||
ColumnSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
String tableName,
|
||||
JaxbColumnElement columnElement,
|
||||
TruthValue isIncludedInInsert,
|
||||
TruthValue isIncludedInUpdate) {
|
||||
this( tableName, columnElement, isIncludedInInsert, isIncludedInUpdate, TruthValue.UNKNOWN );
|
||||
this( mappingDocument, tableName, columnElement, isIncludedInInsert, isIncludedInUpdate, TruthValue.UNKNOWN );
|
||||
}
|
||||
|
||||
ColumnSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
String tableName,
|
||||
JaxbColumnElement columnElement,
|
||||
TruthValue isIncludedInInsert,
|
||||
TruthValue isIncludedInUpdate,
|
||||
TruthValue nullable) {
|
||||
super( mappingDocument );
|
||||
this.tableName = tableName;
|
||||
this.columnElement = columnElement;
|
||||
this.nullable = nullable;
|
||||
|
|
|
@ -39,15 +39,17 @@ import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class CompositePluralAttributeElementSourceImpl implements CompositePluralAttributeElementSource {
|
||||
public class CompositePluralAttributeElementSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements CompositePluralAttributeElementSource {
|
||||
|
||||
private final JaxbCompositeElementElement compositeElement;
|
||||
private final LocalBindingContext bindingContext;
|
||||
|
||||
public CompositePluralAttributeElementSourceImpl(
|
||||
JaxbCompositeElementElement compositeElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument mappingDocument,
|
||||
JaxbCompositeElementElement compositeElement) {
|
||||
super( mappingDocument );
|
||||
this.compositeElement = compositeElement;
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,12 +59,12 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura
|
|||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return bindingContext.qualifyClassName( compositeElement.getClazz() );
|
||||
return bindingContext().qualifyClassName( compositeElement.getClazz() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value<Class<?>> getClassReference() {
|
||||
return bindingContext.makeClassReference( getClassName() );
|
||||
return bindingContext().makeClassReference( getClassName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -103,6 +105,6 @@ public class CompositePluralAttributeElementSourceImpl implements CompositePlura
|
|||
|
||||
@Override
|
||||
public LocalBindingContext getLocalBindingContext() {
|
||||
return bindingContext;
|
||||
return bindingContext();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,17 @@ import org.hibernate.metamodel.spi.source.FetchProfileSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FetchProfileSourceImpl implements FetchProfileSource {
|
||||
public class FetchProfileSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements FetchProfileSource {
|
||||
|
||||
private final String name;
|
||||
private final List<AssociationOverrideSource> associationOverrideSources;
|
||||
|
||||
public FetchProfileSourceImpl(JaxbFetchProfileElement fetchProfileElement) {
|
||||
public FetchProfileSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
JaxbFetchProfileElement fetchProfileElement) {
|
||||
super( mappingDocument );
|
||||
this.name = fetchProfileElement.getName();
|
||||
this.associationOverrideSources = buildAssociationOverrideSources( fetchProfileElement );
|
||||
}
|
||||
|
|
|
@ -33,12 +33,17 @@ import org.hibernate.metamodel.spi.source.FilterParameterSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FilterDefinitionSourceImpl implements FilterDefinitionSource {
|
||||
public class FilterDefinitionSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements FilterDefinitionSource {
|
||||
private final String name;
|
||||
private final String condition;
|
||||
private List<FilterParameterSource> parameterSources;
|
||||
|
||||
public FilterDefinitionSourceImpl(JaxbHibernateMapping.JaxbFilterDef filterDefElement) {
|
||||
public FilterDefinitionSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
JaxbHibernateMapping.JaxbFilterDef filterDefElement) {
|
||||
super( mappingDocument );
|
||||
this.name = filterDefElement.getName();
|
||||
|
||||
String conditionAttribute = filterDefElement.getCondition();
|
||||
|
|
|
@ -29,11 +29,16 @@ import org.hibernate.metamodel.spi.source.FilterSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FilterSourceImpl implements FilterSource {
|
||||
public class FilterSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements FilterSource {
|
||||
private final String name;
|
||||
private final String condition;
|
||||
|
||||
public FilterSourceImpl(JaxbFilterElement filterElement) {
|
||||
public FilterSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
JaxbFilterElement filterElement) {
|
||||
super( mappingDocument );
|
||||
this.name = filterElement.getName();
|
||||
|
||||
String conditionAttribute = filterElement.getCondition();
|
||||
|
|
|
@ -24,16 +24,18 @@
|
|||
package org.hibernate.metamodel.internal.source.hbm;
|
||||
|
||||
import org.hibernate.metamodel.spi.source.DerivedValueSource;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class FormulaImpl implements DerivedValueSource {
|
||||
class FormulaImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements DerivedValueSource {
|
||||
private String tableName;
|
||||
private final String expression;
|
||||
|
||||
FormulaImpl(String tableName, String expression) {
|
||||
FormulaImpl(MappingDocument mappingDocument, String tableName, String expression) {
|
||||
super( mappingDocument );
|
||||
this.tableName = tableName;
|
||||
this.expression = expression;
|
||||
}
|
||||
|
|
|
@ -294,10 +294,12 @@ public class Helper {
|
|||
}
|
||||
|
||||
public static TableSpecificationSource createTableSource(
|
||||
MappingDocument mappingDocument,
|
||||
TableInformationSource jaxbTableSource,
|
||||
InLineViewNameInferrer inLineViewNameInferrer) {
|
||||
if ( jaxbTableSource.getSubselectAttribute() == null && jaxbTableSource.getSubselect() == null ) {
|
||||
return new TableSourceImpl(
|
||||
mappingDocument,
|
||||
jaxbTableSource.getSchema(),
|
||||
jaxbTableSource.getCatalog(),
|
||||
jaxbTableSource.getTable()
|
||||
|
@ -305,6 +307,7 @@ public class Helper {
|
|||
}
|
||||
else {
|
||||
return new InLineViewSourceImpl(
|
||||
mappingDocument,
|
||||
jaxbTableSource.getSchema(),
|
||||
jaxbTableSource.getCatalog(),
|
||||
jaxbTableSource.getSubselectAttribute() != null
|
||||
|
@ -372,8 +375,8 @@ public class Helper {
|
|||
* @return The corresponding list.
|
||||
*/
|
||||
public static List<RelationalValueSource> buildValueSources(
|
||||
ValueSourcesAdapter valueSourcesAdapter,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument mappingDocument,
|
||||
ValueSourcesAdapter valueSourcesAdapter) {
|
||||
List<RelationalValueSource> result = new ArrayList<RelationalValueSource>();
|
||||
|
||||
if ( StringHelper.isNotEmpty( valueSourcesAdapter.getColumnAttribute() ) ) {
|
||||
|
@ -381,21 +384,20 @@ public class Helper {
|
|||
// it is therefore illegal for there to also be any nested formula or column elements
|
||||
if ( valueSourcesAdapter.getColumnOrFormulaElements() != null
|
||||
&& ! valueSourcesAdapter.getColumnOrFormulaElements().isEmpty() ) {
|
||||
throw new MappingException(
|
||||
"column/formula attribute may not be used together with <column>/<formula> subelement",
|
||||
bindingContext.getOrigin()
|
||||
throw mappingDocument.getMappingLocalBindingContext().makeMappingException(
|
||||
"column/formula attribute may not be used together with <column>/<formula> subelement"
|
||||
);
|
||||
}
|
||||
// it is also illegal for there to also be a formula attribute
|
||||
if ( StringHelper.isNotEmpty( valueSourcesAdapter.getFormulaAttribute() ) ) {
|
||||
throw new MappingException(
|
||||
"column and formula attributes may not be used together",
|
||||
bindingContext.getOrigin()
|
||||
throw mappingDocument.getMappingLocalBindingContext().makeMappingException(
|
||||
"column and formula attributes may not be used together"
|
||||
);
|
||||
}
|
||||
|
||||
result.add(
|
||||
new ColumnAttributeSourceImpl(
|
||||
mappingDocument,
|
||||
valueSourcesAdapter.getContainingTableName(),
|
||||
valueSourcesAdapter.getColumnAttribute(),
|
||||
valueSourcesAdapter.isIncludedInInsertByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
|
@ -409,15 +411,15 @@ public class Helper {
|
|||
// it is therefore illegal for there to also be any nested formula or column elements
|
||||
if ( valueSourcesAdapter.getColumnOrFormulaElements() != null
|
||||
&& ! valueSourcesAdapter.getColumnOrFormulaElements().isEmpty() ) {
|
||||
throw new MappingException(
|
||||
"column/formula attribute may not be used together with <column>/<formula> subelement",
|
||||
bindingContext.getOrigin()
|
||||
throw mappingDocument.getMappingLocalBindingContext().makeMappingException(
|
||||
"column/formula attribute may not be used together with <column>/<formula> subelement"
|
||||
);
|
||||
}
|
||||
// column/formula attribute combo checked already
|
||||
|
||||
result.add(
|
||||
new FormulaImpl(
|
||||
mappingDocument,
|
||||
valueSourcesAdapter.getContainingTableName(),
|
||||
valueSourcesAdapter.getFormulaAttribute()
|
||||
)
|
||||
|
@ -430,6 +432,7 @@ public class Helper {
|
|||
if ( JaxbColumnElement.class.isInstance( columnOrFormulaElement ) ) {
|
||||
result.add(
|
||||
new ColumnSourceImpl(
|
||||
mappingDocument,
|
||||
valueSourcesAdapter.getContainingTableName(),
|
||||
(JaxbColumnElement) columnOrFormulaElement,
|
||||
valueSourcesAdapter.isIncludedInInsertByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
|
@ -441,6 +444,7 @@ public class Helper {
|
|||
else {
|
||||
result.add(
|
||||
new FormulaImpl(
|
||||
mappingDocument,
|
||||
valueSourcesAdapter.getContainingTableName(),
|
||||
(String) columnOrFormulaElement
|
||||
)
|
||||
|
|
|
@ -142,7 +142,7 @@ public class HibernateMappingProcessor {
|
|||
}
|
||||
|
||||
for ( JaxbHibernateMapping.JaxbFilterDef filterDefElement : mappingRoot().getFilterDef() ) {
|
||||
filterDefinitionSources.add( new FilterDefinitionSourceImpl( filterDefElement ) );
|
||||
filterDefinitionSources.add( new FilterDefinitionSourceImpl( mappingDocument, filterDefElement ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,9 +82,8 @@ public class HierarchyBuilder {
|
|||
else {
|
||||
// we have to see if this things super-type has been found yet, and if not add it to the
|
||||
// extends queue
|
||||
final String entityItExtends =
|
||||
currentMappingDocument.getMappingLocalBindingContext().
|
||||
qualifyClassName( ( (SubEntityElement) entityElement ).getExtends() );
|
||||
final String entityItExtends = currentMappingDocument.getMappingLocalBindingContext()
|
||||
.qualifyClassName( ( (SubEntityElement) entityElement ).getExtends() );
|
||||
final SubclassEntityContainer container = subEntityContainerMap.get( entityItExtends );
|
||||
final SubclassEntitySourceImpl subClassEntitySource = new SubclassEntitySourceImpl( currentMappingDocument, entityElement, ( EntitySource ) container );
|
||||
final String entityName = subClassEntitySource.getEntityName();
|
||||
|
|
|
@ -28,16 +28,20 @@ import org.hibernate.metamodel.spi.source.InLineViewSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class InLineViewSourceImpl implements InLineViewSource {
|
||||
public class InLineViewSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements InLineViewSource {
|
||||
private final String schemaName;
|
||||
private final String catalogName;
|
||||
private final String selectStatement;
|
||||
private final String logicalName;
|
||||
|
||||
public InLineViewSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
String schemaName,
|
||||
String catalogName,
|
||||
String selectStatement, String logicalName) {
|
||||
super( mappingDocument );
|
||||
this.schemaName = schemaName;
|
||||
this.catalogName = catalogName;
|
||||
this.selectStatement = selectStatement;
|
||||
|
|
|
@ -27,12 +27,10 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbManyToManyElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.PluralAttributeElement;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
|
||||
import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
|
@ -40,22 +38,24 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPluralAttributeElementSource {
|
||||
public class ManyToManyPluralAttributeElementSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements ManyToManyPluralAttributeElementSource {
|
||||
private final PluralAttributeElement pluralAttributeElement;
|
||||
private final JaxbManyToManyElement manyToManyElement;
|
||||
private final LocalBindingContext bindingContext;
|
||||
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
|
||||
public ManyToManyPluralAttributeElementSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
final PluralAttributeElement pluralAttributeElement,
|
||||
final JaxbManyToManyElement manyToManyElement,
|
||||
final LocalBindingContext bindingContext) {
|
||||
final JaxbManyToManyElement manyToManyElement) {
|
||||
super( mappingDocument );
|
||||
this.pluralAttributeElement = pluralAttributeElement;
|
||||
this.manyToManyElement = manyToManyElement;
|
||||
this.bindingContext = bindingContext;
|
||||
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getContainingTableName() {
|
||||
|
@ -86,8 +86,7 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
|
|||
public List getColumnOrFormulaElements() {
|
||||
return manyToManyElement.getColumnOrFormula();
|
||||
}
|
||||
},
|
||||
bindingContext
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -100,7 +99,7 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
|
|||
public String getReferencedEntityName() {
|
||||
return StringHelper.isNotEmpty( manyToManyElement.getEntityName() )
|
||||
? manyToManyElement.getEntityName()
|
||||
: bindingContext.qualifyClassName( manyToManyElement.getClazz() );
|
||||
: bindingContext().qualifyClassName( manyToManyElement.getClazz() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,7 +145,7 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
|
|||
|
||||
@Override
|
||||
public Iterable<CascadeStyle> getCascadeStyles() {
|
||||
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext );
|
||||
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -158,12 +157,11 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
|
|||
}
|
||||
|
||||
if ( manyToManyElement.getOuterJoin() == null ) {
|
||||
return !bindingContext.getMappingDefaults().areAssociationsLazy();
|
||||
return !bindingContext().getMappingDefaults().areAssociationsLazy();
|
||||
}
|
||||
else {
|
||||
final String value = manyToManyElement.getOuterJoin().value();
|
||||
if ( "auto".equals( value ) ) {
|
||||
return !bindingContext.getMappingDefaults().areAssociationsLazy();
|
||||
}
|
||||
return "true".equals( value );
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ class ManyToOneAttributeSourceImpl extends AbstractHbmSourceNode implements ToOn
|
|||
this.manyToOneElement = manyToOneElement;
|
||||
this.naturalIdMutability = naturalIdMutability;
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getColumnAttribute() {
|
||||
|
@ -87,8 +88,7 @@ class ManyToOneAttributeSourceImpl extends AbstractHbmSourceNode implements ToOn
|
|||
public boolean isIncludedInUpdateByDefault() {
|
||||
return manyToOneElement.isUpdate();
|
||||
}
|
||||
},
|
||||
bindingContext()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,18 +34,19 @@ import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPluralAttributeElementSource {
|
||||
public class OneToManyPluralAttributeElementSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements OneToManyPluralAttributeElementSource {
|
||||
private final PluralAttributeElement pluralAttributeElement;
|
||||
private final JaxbOneToManyElement oneToManyElement;
|
||||
private final LocalBindingContext bindingContext;
|
||||
|
||||
public OneToManyPluralAttributeElementSourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
PluralAttributeElement pluralAttributeElement,
|
||||
JaxbOneToManyElement oneToManyElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
JaxbOneToManyElement oneToManyElement) {
|
||||
super( mappingDocument );
|
||||
this.pluralAttributeElement = pluralAttributeElement;
|
||||
this.oneToManyElement = oneToManyElement;
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,7 +58,7 @@ public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPlura
|
|||
public String getReferencedEntityName() {
|
||||
return StringHelper.isNotEmpty( oneToManyElement.getEntityName() )
|
||||
? oneToManyElement.getEntityName()
|
||||
: bindingContext.qualifyClassName( oneToManyElement.getClazz() );
|
||||
: bindingContext().qualifyClassName( oneToManyElement.getClazz() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,6 +69,6 @@ public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPlura
|
|||
|
||||
@Override
|
||||
public Iterable<CascadeStyle> getCascadeStyles() {
|
||||
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext );
|
||||
return Helper.interpretCascadeStyles( pluralAttributeElement.getCascade(), bindingContext() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,17 +34,22 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class PluralAttributeKeySourceImpl implements PluralAttributeKeySource {
|
||||
public class PluralAttributeKeySourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements PluralAttributeKeySource {
|
||||
private final JaxbKeyElement keyElement;
|
||||
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
|
||||
public PluralAttributeKeySourceImpl(
|
||||
MappingDocument mappingDocument,
|
||||
final JaxbKeyElement keyElement,
|
||||
final AttributeSourceContainer container) {
|
||||
super( mappingDocument );
|
||||
this.keyElement = keyElement;
|
||||
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getContainingTableName() {
|
||||
|
@ -75,8 +80,7 @@ public class PluralAttributeKeySourceImpl implements PluralAttributeKeySource {
|
|||
public List getColumnOrFormulaElements() {
|
||||
return keyElement.getColumn();
|
||||
}
|
||||
},
|
||||
container.getLocalBindingContext()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ class PropertyAttributeSourceImpl extends AbstractHbmSourceNode implements Singu
|
|||
}
|
||||
};
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getColumnAttribute() {
|
||||
|
@ -103,8 +104,7 @@ class PropertyAttributeSourceImpl extends AbstractHbmSourceNode implements Singu
|
|||
public boolean isIncludedInUpdateByDefault() {
|
||||
return Helper.getBooleanValue( propertyElement.isUpdate(), true );
|
||||
}
|
||||
},
|
||||
bindingContext()
|
||||
}
|
||||
);
|
||||
this.naturalIdMutability = naturalIdMutability;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
|||
import org.hibernate.metamodel.spi.source.RootEntitySource;
|
||||
import org.hibernate.metamodel.spi.source.SimpleIdentifierSource;
|
||||
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.SubclassEntitySource;
|
||||
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
|
||||
import org.hibernate.metamodel.spi.source.VersionAttributeSource;
|
||||
|
||||
|
@ -57,7 +56,7 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
MappingDocument sourceMappingDocument,
|
||||
JaxbHibernateMapping.JaxbClass entityElement) {
|
||||
super( sourceMappingDocument, entityElement );
|
||||
this.primaryTable = Helper.createTableSource( entityElement, this );
|
||||
this.primaryTable = Helper.createTableSource( sourceMappingDocument(), entityElement, this );
|
||||
|
||||
afterInstantiation();
|
||||
}
|
||||
|
@ -74,8 +73,8 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
@Override
|
||||
public SingularAttributeSource getIdentifierAttributeSource() {
|
||||
return new SingularIdentifierAttributeSourceImpl(
|
||||
entityElement().getId(),
|
||||
sourceMappingDocument().getMappingLocalBindingContext()
|
||||
sourceMappingDocument(),
|
||||
entityElement().getId()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -111,14 +110,14 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
public VersionAttributeSource getVersioningAttributeSource() {
|
||||
if ( entityElement().getVersion() != null ) {
|
||||
return new VersionAttributeSourceImpl(
|
||||
entityElement().getVersion(),
|
||||
sourceMappingDocument().getMappingLocalBindingContext()
|
||||
sourceMappingDocument(),
|
||||
entityElement().getVersion()
|
||||
);
|
||||
}
|
||||
else if ( entityElement().getTimestamp() != null ) {
|
||||
return new TimestampAttributeSourceImpl(
|
||||
entityElement().getTimestamp(),
|
||||
sourceMappingDocument().getMappingLocalBindingContext()
|
||||
sourceMappingDocument(),
|
||||
entityElement().getTimestamp()
|
||||
);
|
||||
}
|
||||
return null;
|
||||
|
@ -222,6 +221,7 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
public RelationalValueSource getDiscriminatorRelationalValueSource() {
|
||||
if ( StringHelper.isNotEmpty( discriminatorElement.getColumnAttribute() ) ) {
|
||||
return new ColumnAttributeSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
null, // root table
|
||||
discriminatorElement.getColumnAttribute(),
|
||||
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
|
@ -229,10 +229,15 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
);
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( discriminatorElement.getFormulaAttribute() ) ) {
|
||||
return new FormulaImpl( null, discriminatorElement.getFormulaAttribute() );
|
||||
return new FormulaImpl(
|
||||
sourceMappingDocument(),
|
||||
null,
|
||||
discriminatorElement.getFormulaAttribute()
|
||||
);
|
||||
}
|
||||
else if ( discriminatorElement.getColumn() != null ) {
|
||||
return new ColumnSourceImpl(
|
||||
sourceMappingDocument(),
|
||||
null, // root table
|
||||
discriminatorElement.getColumn(),
|
||||
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
|
||||
|
@ -240,7 +245,11 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
);
|
||||
}
|
||||
else if ( StringHelper.isNotEmpty( discriminatorElement.getFormula() ) ) {
|
||||
return new FormulaImpl( null, discriminatorElement.getFormula() );
|
||||
return new FormulaImpl(
|
||||
sourceMappingDocument(),
|
||||
null,
|
||||
discriminatorElement.getFormula()
|
||||
);
|
||||
}
|
||||
else {
|
||||
throw new MappingException( "could not determine source of discriminator mapping", getOrigin() );
|
||||
|
|
|
@ -48,7 +48,7 @@ class SecondaryTableSourceImpl extends AbstractHbmSourceNode implements Secondar
|
|||
Helper.InLineViewNameInferrer inLineViewNameInferrer) {
|
||||
super( sourceMappingDocument );
|
||||
this.joinElement = joinElement;
|
||||
this.joinTable = Helper.createTableSource( joinElement, inLineViewNameInferrer );
|
||||
this.joinTable = Helper.createTableSource( sourceMappingDocument(), joinElement, inLineViewNameInferrer );
|
||||
|
||||
joinColumns = new ArrayList<PrimaryKeyJoinColumnSource>();
|
||||
if ( joinElement.getKey().getColumnAttribute() != null ) {
|
||||
|
|
|
@ -34,8 +34,11 @@ import org.hibernate.metamodel.spi.source.Sortable;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SetAttributeSourceImpl extends AbstractPluralAttributeSourceImpl implements Orderable, Sortable {
|
||||
public SetAttributeSourceImpl(JaxbSetElement setElement, AttributeSourceContainer container) {
|
||||
super( setElement, container );
|
||||
public SetAttributeSourceImpl(
|
||||
MappingDocument sourceMappingDocument,
|
||||
JaxbSetElement setElement,
|
||||
AttributeSourceContainer container) {
|
||||
super( sourceMappingDocument, setElement, container );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,14 +40,17 @@ import org.hibernate.metamodel.spi.source.SingularAttributeSource;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class SingularIdentifierAttributeSourceImpl implements SingularAttributeSource {
|
||||
class SingularIdentifierAttributeSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements SingularAttributeSource {
|
||||
private final JaxbHibernateMapping.JaxbClass.JaxbId idElement;
|
||||
private final ExplicitHibernateTypeSource typeSource;
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
|
||||
public SingularIdentifierAttributeSourceImpl(
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbId idElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument mappingDocument,
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbId idElement) {
|
||||
super( mappingDocument );
|
||||
this.idElement = idElement;
|
||||
this.typeSource = new ExplicitHibernateTypeSource() {
|
||||
private final String name = idElement.getTypeAttribute() != null
|
||||
|
@ -70,6 +73,7 @@ class SingularIdentifierAttributeSourceImpl implements SingularAttributeSource {
|
|||
}
|
||||
};
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getColumnAttribute() {
|
||||
|
@ -106,8 +110,7 @@ class SingularIdentifierAttributeSourceImpl implements SingularAttributeSource {
|
|||
public boolean isForceNotNull() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
bindingContext
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.internal.source.hbm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.EntityElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbSubclassElement;
|
||||
import org.hibernate.internal.jaxb.mapping.hbm.TableInformationSource;
|
||||
|
@ -46,8 +44,10 @@ public class SubclassEntitySourceImpl extends AbstractEntitySourceImpl implement
|
|||
super( sourceMappingDocument, entityElement );
|
||||
this.container = container;
|
||||
this.primaryTable = TableInformationSource.class.isInstance( entityElement )
|
||||
? Helper.createTableSource( (TableInformationSource) entityElement, this )
|
||||
? Helper.createTableSource( sourceMappingDocument(), (TableInformationSource) entityElement, this )
|
||||
: null;
|
||||
|
||||
afterInstantiation();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,12 +28,15 @@ import org.hibernate.metamodel.spi.source.TableSource;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableSourceImpl implements TableSource {
|
||||
public class TableSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements TableSource {
|
||||
private final String schema;
|
||||
private final String catalog;
|
||||
private final String tableName;
|
||||
|
||||
TableSourceImpl(String schema, String catalog, String tableName) {
|
||||
TableSourceImpl(MappingDocument mappingDocument, String schema, String catalog, String tableName) {
|
||||
super( mappingDocument );
|
||||
this.schema = schema;
|
||||
this.catalog = catalog;
|
||||
this.tableName = tableName;
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping;
|
|||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.spi.source.MappingException;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
import org.hibernate.metamodel.spi.source.SingularAttributeNature;
|
||||
|
@ -42,17 +40,19 @@ import org.hibernate.metamodel.spi.source.VersionAttributeSource;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class TimestampAttributeSourceImpl implements VersionAttributeSource {
|
||||
class TimestampAttributeSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements VersionAttributeSource {
|
||||
private final JaxbHibernateMapping.JaxbClass.JaxbTimestamp timestampElement;
|
||||
private final LocalBindingContext bindingContext;
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
|
||||
TimestampAttributeSourceImpl(
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbTimestamp timestampElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument mappingDocument,
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbTimestamp timestampElement) {
|
||||
super( mappingDocument );
|
||||
this.timestampElement = timestampElement;
|
||||
this.bindingContext = bindingContext;
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getColumnAttribute() {
|
||||
|
@ -84,8 +84,7 @@ class TimestampAttributeSourceImpl implements VersionAttributeSource {
|
|||
public boolean isIncludedInUpdateByDefault() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
bindingContext
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -124,10 +123,7 @@ class TimestampAttributeSourceImpl implements VersionAttributeSource {
|
|||
? PropertyGeneration.NEVER
|
||||
: PropertyGeneration.parse( timestampElement.getGenerated().value() );
|
||||
if ( propertyGeneration == PropertyGeneration.INSERT ) {
|
||||
throw new MappingException(
|
||||
"'generated' attribute cannot be 'insert' for versioning property",
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
throw makeMappingException( "'generated' attribute cannot be 'insert' for versioning property" );
|
||||
}
|
||||
return propertyGeneration;
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ import java.util.Map;
|
|||
import org.hibernate.internal.jaxb.mapping.hbm.JaxbHibernateMapping;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.spi.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.spi.source.MappingException;
|
||||
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
|
||||
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
|
||||
import org.hibernate.metamodel.spi.source.RelationalValueSource;
|
||||
|
@ -43,17 +41,19 @@ import org.hibernate.metamodel.spi.source.VersionAttributeSource;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
class VersionAttributeSourceImpl implements VersionAttributeSource {
|
||||
class VersionAttributeSourceImpl
|
||||
extends AbstractHbmSourceNode
|
||||
implements VersionAttributeSource {
|
||||
private final JaxbHibernateMapping.JaxbClass.JaxbVersion versionElement;
|
||||
private final LocalBindingContext bindingContext;
|
||||
private final List<RelationalValueSource> valueSources;
|
||||
|
||||
VersionAttributeSourceImpl(
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbVersion versionElement,
|
||||
LocalBindingContext bindingContext) {
|
||||
MappingDocument mappingDocument,
|
||||
final JaxbHibernateMapping.JaxbClass.JaxbVersion versionElement) {
|
||||
super( mappingDocument );
|
||||
this.versionElement = versionElement;
|
||||
this.bindingContext = bindingContext;
|
||||
this.valueSources = Helper.buildValueSources(
|
||||
sourceMappingDocument(),
|
||||
new Helper.ValueSourcesAdapter() {
|
||||
@Override
|
||||
public String getColumnAttribute() {
|
||||
|
@ -85,8 +85,7 @@ class VersionAttributeSourceImpl implements VersionAttributeSource {
|
|||
public boolean isIncludedInUpdateByDefault() {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
bindingContext
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -130,10 +129,7 @@ class VersionAttributeSourceImpl implements VersionAttributeSource {
|
|||
? PropertyGeneration.NEVER
|
||||
: PropertyGeneration.parse( versionElement.getGenerated().value() );
|
||||
if ( propertyGeneration == PropertyGeneration.INSERT ) {
|
||||
throw new MappingException(
|
||||
"'generated' attribute cannot be 'insert' for versioning property",
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
throw makeMappingException( "'generated' attribute cannot be 'insert' for versioning property" );
|
||||
}
|
||||
return propertyGeneration;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue