HHH-8078 : Non-default column length, precision, and scale are incorrect

This commit is contained in:
Gail Badner 2013-03-15 18:16:32 -07:00
parent 7da7f28902
commit 1bd4856d8b
18 changed files with 367 additions and 31 deletions

View File

@ -114,6 +114,7 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.metamodel.spi.relational.PrimaryKey;
import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.relational.Table;
import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.metamodel.spi.relational.UniqueKey;
@ -140,7 +141,6 @@ import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.InLineViewSource;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.JoinedSubclassEntitySource;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSourceResolver;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
@ -161,6 +161,7 @@ import org.hibernate.metamodel.spi.source.SecondaryTableSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.SimpleIdentifierSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.SizeSource;
import org.hibernate.metamodel.spi.source.Sortable;
import org.hibernate.metamodel.spi.source.TableSource;
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
@ -175,6 +176,8 @@ import org.hibernate.tuple.entity.EntityTuplizer;
import org.hibernate.type.ComponentType;
import org.hibernate.type.EntityType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.SingleColumnType;
import org.hibernate.type.StringType;
import org.hibernate.type.Type;
import org.jboss.logging.Logger;
@ -2902,7 +2905,18 @@ public class Binder {
resolveColumnNullable( columnSource, forceNotNull, isNullableByDefault, column );
column.setDefaultValue( columnSource.getDefaultValue() );
column.setSqlType( columnSource.getSqlType() );
column.setSize( columnSource.getSize() );
if ( columnSource.getSizeSource() != null ) {
final SizeSource sizeSource = columnSource.getSizeSource();
if ( sizeSource.isLengthDefined() ) {
column.getSize().setLength( sizeSource.getLength() );
}
if ( sizeSource.isPrecisionDefined() ) {
column.getSize().setPrecision( sizeSource.getPrecision() );
}
if ( sizeSource.isScaleDefined() ) {
column.getSize().setScale( sizeSource.getScale() );
}
}
column.setJdbcDataType( columnSource.getDatatype() );
column.setReadFragment( columnSource.getReadFragment() );
column.setWriteFragment( columnSource.getWriteFragment() );

View File

@ -26,8 +26,8 @@ package org.hibernate.metamodel.internal.source.annotations;
import org.hibernate.TruthValue;
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.source.ColumnSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* @author Steve Ebersole
@ -76,13 +76,10 @@ public class ColumnValuesSourceImpl implements ColumnSource {
}
@Override
public Size getSize() {
public SizeSource getSizeSource() {
if(columnValues == null) return null;
return new Size(
columnValues.getPrecision(),
columnValues.getScale(),
columnValues.getLength(),
Size.LobMultiplier.NONE
return new SizeSourceImpl(
columnValues.getPrecision(), columnValues.getScale(), columnValues.getLength()
);
}

View File

@ -0,0 +1,66 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* @author Gail Badner
*/
public class SizeSourceImpl implements SizeSource {
private final int length;
private final int precision;
private final int scale;
public SizeSourceImpl(int precision, int scale, int length) {
this.precision = precision;
this.scale = scale;
this.length = length;
}
public boolean isLengthDefined() {
return true;
}
public int getLength() {
return length;
}
public boolean isPrecisionDefined() {
return true;
}
public int getPrecision() {
return precision;
}
public boolean isScaleDefined() {
return true;
}
public int getScale() {
return scale;
}
}

View File

@ -31,6 +31,7 @@ import org.hibernate.jaxb.spi.hbm.JaxbElementElement;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* @author Steve Ebersole
@ -68,6 +69,15 @@ public class BasicPluralAttributeElementSourceImpl
return elementElement.getFormulaAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
elementElement.getLength(),
elementElement.getPrecision(),
elementElement.getScale()
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return elementElement.getColumn();

View File

@ -25,8 +25,8 @@ package org.hibernate.metamodel.internal.source.hbm;
import org.hibernate.TruthValue;
import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.source.ColumnSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* Implementation of a {@link ColumnSource} when the column is declared as just the name via the column XML
@ -39,6 +39,7 @@ class ColumnAttributeSourceImpl
implements ColumnSource {
private final String tableName;
private final String columnName;
private final SizeSource sizeSource;
private TruthValue includedInInsert;
private TruthValue includedInUpdate;
private TruthValue nullable;
@ -47,21 +48,24 @@ class ColumnAttributeSourceImpl
MappingDocument mappingDocument,
String tableName,
String columnName,
SizeSource sizeSource,
TruthValue includedInInsert,
TruthValue includedInUpdate) {
this( mappingDocument, tableName, columnName, includedInInsert, includedInUpdate, TruthValue.UNKNOWN );
this( mappingDocument, tableName, columnName, sizeSource, includedInInsert, includedInUpdate, TruthValue.UNKNOWN );
}
ColumnAttributeSourceImpl(
MappingDocument mappingDocument,
String tableName,
String columnName,
SizeSource sizeSource,
TruthValue includedInInsert,
TruthValue includedInUpdate,
TruthValue nullable) {
super( mappingDocument );
this.tableName = tableName;
this.columnName = columnName;
this.sizeSource = sizeSource;
this.includedInInsert = includedInInsert;
this.includedInUpdate = includedInUpdate;
this.nullable = nullable;
@ -113,8 +117,8 @@ class ColumnAttributeSourceImpl
}
@Override
public Size getSize() {
return null;
public SizeSource getSizeSource() {
return sizeSource;
}
@Override

View File

@ -26,8 +26,8 @@ package org.hibernate.metamodel.internal.source.hbm;
import org.hibernate.TruthValue;
import org.hibernate.jaxb.spi.hbm.JaxbColumnElement;
import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Size;
import org.hibernate.metamodel.spi.source.ColumnSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* @author Steve Ebersole
@ -96,13 +96,8 @@ class ColumnSourceImpl
}
@Override
public Size getSize() {
return new Size(
Helper.getValue( columnElement.getPrecision(), Size.DEFAULT_PRECISION ),
Helper.getValue( columnElement.getScale(), Size.DEFAULT_SCALE ),
Helper.getValue( columnElement.getLength(), Size.DEFAULT_LENGTH ),
Size.LobMultiplier.NONE
);
public SizeSource getSizeSource() {
return new SizeSourceImpl( columnElement.getPrecision(), columnElement.getScale(), columnElement.getLength() );
}
@Override

View File

@ -64,6 +64,7 @@ import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SizeSource;
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
/**
@ -269,7 +270,12 @@ public class Helper {
return params;
}
public static SizeSource createSizeSourceIfMapped(Integer length, Integer precision, Integer scale) {
if ( length != null || precision != null || scale != null ) {
return new SizeSourceImpl( precision, scale, length );
}
return null;
}
public static Schema.Name determineDatabaseSchemaName(
String explicitSchemaName,
@ -391,6 +397,10 @@ public class Helper {
return null;
}
public SizeSource getSizeSource() {
return null;
}
public List<JaxbColumnElement> getColumn(){
return Collections.emptyList();
}
@ -409,7 +419,7 @@ public class Helper {
valueSourcesAdapter.getFormula()
) ) {
throw mappingDocument.getMappingLocalBindingContext().makeMappingException(
"column/formula attribute may not be used together with <column>/<formula> subelement"
"column/formula/size attribute may not be used together with <column>/<formula> subelement"
);
}
}
@ -443,6 +453,7 @@ public class Helper {
mappingDocument,
valueSourcesAdapter.getContainingTableName(),
valueSourcesAdapter.getColumnAttribute(),
valueSourcesAdapter.getSizeSource(),
valueSourcesAdapter.isIncludedInInsertByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
valueSourcesAdapter.isIncludedInUpdateByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
valueSourcesAdapter.isForceNotNull() ? TruthValue.FALSE : TruthValue.UNKNOWN
@ -463,6 +474,24 @@ public class Helper {
)
);
}
else if ( valueSourcesAdapter.getSizeSource() != null ) {
// we have XML defining a length, precision, and/or scale attribute with neither
// a column nor formula attribute; assume this is a column.
// it is therefore illegal for there to also be any nested formula or column elements
checkColumnOrFormulaElements(mappingDocument, valueSourcesAdapter);
result.add(
new ColumnAttributeSourceImpl(
mappingDocument,
valueSourcesAdapter.getContainingTableName(),
valueSourcesAdapter.getColumnAttribute(),
valueSourcesAdapter.getSizeSource(),
valueSourcesAdapter.isIncludedInInsertByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
valueSourcesAdapter.isIncludedInUpdateByDefault() ? TruthValue.TRUE : TruthValue.FALSE,
valueSourcesAdapter.isForceNotNull() ? TruthValue.FALSE : TruthValue.UNKNOWN
)
);
}
// we have the XML defining nested formula or column elements (and not column attribute nor formula attribute)
if ( CollectionHelper.isNotEmpty( valueSourcesAdapter.getColumn() ) ) {
for ( JaxbColumnElement column : valueSourcesAdapter.getColumn() ) {

View File

@ -34,6 +34,7 @@ import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* Implementation for {@code <key-property/>} mappings
@ -83,6 +84,16 @@ class KeyAttributeSourceImpl
return keyPropertyElement.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
keyPropertyElement.getLength(),
null,
null
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return keyPropertyElement.getColumn();

View File

@ -33,6 +33,7 @@ import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
*
@ -53,6 +54,16 @@ public class MapKeySourceImpl extends AbstractHbmSourceNode implements BasicPlur
return mapKey.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
mapKey.getLength(),
null,
null
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return mapKey.getColumn();
@ -112,6 +123,16 @@ public class MapKeySourceImpl extends AbstractHbmSourceNode implements BasicPlur
return indexElement.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
indexElement.getLength(),
null,
null
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return indexElement.getColumn();

View File

@ -31,7 +31,6 @@ import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.metamodel.spi.source.AttributeSourceContainer;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource;
import org.hibernate.metamodel.spi.source.PluralAttributeKeySource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;

View File

@ -34,6 +34,7 @@ import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* Implementation for {@code <property/>} mappings
@ -83,6 +84,17 @@ class PropertyAttributeSourceImpl extends AbstractHbmSourceNode implements Singu
return propertyElement.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
// TODO: propertyElement.getPrecision() and getScale() return String,
// but should return int
return Helper.createSizeSourceIfMapped(
propertyElement.getLength(),
propertyElement.getPrecision() == null ? null : Integer.valueOf( propertyElement.getPrecision() ),
propertyElement.getScale() == null ? null : Integer.valueOf( propertyElement.getScale() )
);
}
@Override
public String getFormulaAttribute() {
return propertyElement.getFormulaAttribute();

View File

@ -36,7 +36,6 @@ import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jaxb.spi.hbm.JaxbClassElement;
import org.hibernate.jaxb.spi.hbm.JaxbCompositeIdElement;
import org.hibernate.jaxb.spi.hbm.JaxbDiscriminatorElement;
import org.hibernate.jaxb.spi.hbm.JaxbFilterElement;
import org.hibernate.jaxb.spi.hbm.JaxbKeyManyToOneElement;
import org.hibernate.jaxb.spi.hbm.JaxbKeyPropertyElement;
import org.hibernate.jaxb.spi.hbm.JaxbMultiTenancyElement;
@ -50,7 +49,6 @@ import org.hibernate.metamodel.spi.source.AggregatedCompositeIdentifierSource;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
import org.hibernate.metamodel.spi.source.DiscriminatorSource;
import org.hibernate.metamodel.spi.source.FilterSource;
import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
@ -60,6 +58,7 @@ 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.SizeSource;
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
import org.hibernate.metamodel.spi.source.VersionAttributeSource;
@ -222,11 +221,13 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
return new DiscriminatorSource() {
@Override
public RelationalValueSource getDiscriminatorRelationalValueSource() {
if ( StringHelper.isNotEmpty( discriminatorElement.getColumnAttribute() ) ) {
SizeSource sizeSource = Helper.createSizeSourceIfMapped( discriminatorElement.getLength(), null, null );
if ( StringHelper.isNotEmpty( discriminatorElement.getColumnAttribute() ) || sizeSource != null ) {
return new ColumnAttributeSourceImpl(
sourceMappingDocument(),
null, // root table
discriminatorElement.getColumnAttribute(),
sizeSource,
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
discriminatorElement.isInsert() ? TruthValue.TRUE : TruthValue.FALSE,
discriminatorElement.isNotNull() ? TruthValue.FALSE : TruthValue.TRUE
@ -293,6 +294,7 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
sourceMappingDocument(),
null, // root table
jaxbMultiTenancy.getColumnAttribute(),
null,
TruthValue.TRUE,
TruthValue.FALSE
);

View File

@ -35,6 +35,7 @@ import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
*
@ -94,6 +95,14 @@ public class SequentialPluralAttributeIndexSourceImpl extends AbstractHbmSourceN
return indexElement.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
indexElement.getLength(),
null,
null
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return indexElement.getColumn();

View File

@ -34,6 +34,7 @@ import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* Implementation for {@code <id/>} mappings
@ -80,6 +81,15 @@ class SingularIdentifierAttributeSourceImpl
return idElement.getColumnAttribute();
}
@Override
public SizeSource getSizeSource() {
return Helper.createSizeSourceIfMapped(
idElement.getLength(),
null,
null
);
}
@Override
public List<JaxbColumnElement> getColumn() {
return idElement.getColumn();

View File

@ -0,0 +1,75 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.hbm;
import org.hibernate.metamodel.spi.source.SizeSource;
/**
* @author Gail Badner
*/
public class SizeSourceImpl implements SizeSource {
private final Integer length;
private final Integer precision;
private final Integer scale;
public SizeSourceImpl(Integer precision, Integer scale, Integer length) {
this.precision = precision;
this.scale = scale;
this.length = length;
}
public boolean isLengthDefined() {
return length != null;
}
public int getLength() {
if ( length == null ) {
throw new UnsupportedOperationException( "length is undefined." );
}
return length;
}
public boolean isPrecisionDefined() {
return precision != null;
}
public int getPrecision() {
if ( precision == null ) {
throw new UnsupportedOperationException( "precision is undefined." );
}
return precision;
}
public boolean isScaleDefined() {
return scale != null;
}
public int getScale() {
if ( scale == null ) {
throw new UnsupportedOperationException( "scale is undefined." );
}
return scale;
}
}

View File

@ -115,6 +115,7 @@ public class Size implements Serializable {
this.precision = size.precision;
this.scale = size.scale;
this.length = size.length;
this.lobMultiplier = size.lobMultiplier;
}
public void setPrecision(int precision) {

View File

@ -25,7 +25,6 @@ package org.hibernate.metamodel.spi.source;
import org.hibernate.TruthValue;
import org.hibernate.metamodel.spi.relational.JdbcDataType;
import org.hibernate.metamodel.spi.relational.Size;
/**
* Contract for source information pertaining to a physical column definition specific to a particular attribute
@ -88,11 +87,11 @@ public interface ColumnSource extends RelationalValueSource {
public JdbcDataType getDatatype();
/**
* Obtain the specified column size.
* Obtain the source for the specified column size.
*
* @return The column size.
* @return The source for the column size.
*/
public Size getSize();
public SizeSource getSizeSource();
/**
* Is this column unique?

View File

@ -0,0 +1,82 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source;
/**
* @author Gail Badner
*/
public interface SizeSource {
/**
* Is length defined?
*
* @return true, if length is defined; false, otherwise.
*/
public boolean isLengthDefined();
/**
* If length is defined (as determined by {@link #isLengthDefined()}), then
* the length is returned.
*
* @return the length, if defined.
* @throws UnsupportedOperationException if length is not defined.
*/
public int getLength();
/**
* Is precision defined?
*
* @return true, if precision is defined; false, otherwise.
*/
public boolean isPrecisionDefined();
/**
* If precision is defined (as determined by {@link #isPrecisionDefined()}), then
* the precision is returned.
*
* @return the precision, if defined.
* @throws UnsupportedOperationException if precision is not defined.
*
* @see {@link #isPrecisionDefined()}
*/
public int getPrecision();
/**
* Is scale defined?
*
* @return true, if scale is defined; false, otherwise.
*/
public boolean isScaleDefined();
/**
* If scale is defined (as determined by {@link #isScaleDefined()}), then
* the scale is returned.
*
* @return the scale, if defined.
* @throws UnsupportedOperationException if scale is not defined.
*
* @see {@link #isScaleDefined()}
*/
public int getScale();
}