HHH-6213 : Move domain and relational state interfaces into org.hibernate.metamodel.state

This commit is contained in:
Gail Badner 2011-05-09 10:30:58 -05:00
parent 66a641df05
commit e98b3ac727
36 changed files with 712 additions and 274 deletions

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.MappingException;
import org.hibernate.metamodel.domain.Attribute;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.relational.Column;
@ -39,6 +38,10 @@ import org.hibernate.metamodel.relational.SimpleValue;
import org.hibernate.metamodel.relational.TableSpecification;
import org.hibernate.metamodel.relational.Tuple;
import org.hibernate.metamodel.relational.Value;
import org.hibernate.metamodel.relational.ValueFactory;
import org.hibernate.metamodel.state.domain.AttributeDomainState;
import org.hibernate.metamodel.state.relational.ValueRelationalState;
import org.hibernate.metamodel.state.relational.TupleRelationalState;
/**
* TODO : javadoc
@ -46,17 +49,6 @@ import org.hibernate.metamodel.relational.Value;
* @author Steve Ebersole
*/
public abstract class AbstractAttributeBinding implements AttributeBinding {
public static interface DomainState {
HibernateTypeDescriptor getHibernateTypeDescriptor();
Attribute getAttribute();
boolean isLazy();
String getPropertyAccessorName();
boolean isAlternateUniqueKey();
String getCascade();
boolean isOptimisticLockable();
String getNodeName();
Map<String, MetaAttribute> getMetaAttributes(EntityBinding entityBinding);
}
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
private final EntityBinding entityBinding;
@ -81,7 +73,7 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
this.entityBinding = entityBinding;
}
protected void initialize(DomainState state) {
protected void initialize(AttributeDomainState state) {
hibernateTypeDescriptor.initialize( state.getHibernateTypeDescriptor() );
attribute = state.getAttribute();
isLazy = state.isLazy();
@ -90,7 +82,7 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
cascade = state.getCascade();
optimisticLockable = state.isOptimisticLockable();
nodeName = state.getNodeName();
metaAttributes = state.getMetaAttributes( entityBinding );
metaAttributes = state.getMetaAttributes();
}
@Override
@ -115,94 +107,24 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
return false;
}
protected void initializeColumnValue(ColumnRelationalState state) {
value = createColumn( state );
protected void initializeValue(ValueRelationalState state) {
value = ValueFactory.createValue( getEntityBinding().getBaseTable(),
getAttribute().getName(),
convertToSimpleRelationalStateIfPossible( state ),
forceNonNullable(),
forceUnique()
);
}
private Column createColumn(ColumnRelationalState state) {
final String explicitName = state.getExplicitColumnName();
final String logicalColumnName = state.getNamingStrategy().logicalColumnName( explicitName, getAttribute().getName() );
final TableSpecification table = getEntityBinding().getBaseTable();
final String columnName =
explicitName == null ?
state.getNamingStrategy().propertyToColumnName( getAttribute().getName() ) :
state.getNamingStrategy().columnName( explicitName );
// todo : find out the purpose of these logical bindings
// mappings.addColumnBinding( logicalColumnName, column, table );
Column columnValue = table.createColumn( columnName );
columnValue.getSize().initialize( state.getSize() );
columnValue.setNullable( ! forceNonNullable() && state.isNullable() );
columnValue.setUnique( ! forceUnique() && state.isUnique() );
columnValue.setCheckCondition( state.getCheckCondition() );
columnValue.setDefaultValue( state.getDefault() );
columnValue.setSqlType( state.getSqlType() );
columnValue.setWriteFragment( state.getCustomWriteFragment() );
columnValue.setReadFragment( state.getCustomReadFragment() );
columnValue.setComment( state.getComment() );
for ( String uniqueKey : state.getUniqueKeys() ) {
table.getOrCreateUniqueKey( uniqueKey ).addColumn( columnValue );
// TODO: should a single-valued tuple always be converted???
protected ValueRelationalState convertToSimpleRelationalStateIfPossible(ValueRelationalState state) {
if ( !TupleRelationalState.class.isInstance( state ) ) {
return state;
}
for ( String index : state.getIndexes() ) {
table.getOrCreateIndex( index ).addColumn( columnValue );
}
return columnValue;
}
// TODO: move this logic out...
protected void initialize(RelationalState state) {
if ( SingleValueRelationalState.class.isInstance( state ) ) {
initializeSingleValue( SingleValueRelationalState.class.cast( state ) );
}
else if ( SimpleTupleRelationalState.class.isInstance( state ) ) {
initializeSimpleTupleValue( SimpleTupleRelationalState.class.cast( state ) );
}
else {
throw new MappingException( "Unexpected type of RelationalState" + state.getClass().getName() );
}
}
protected <T extends DerivedRelationalState> void initializeDerivedValue(T state) {
value = createDerivedValue( state );
}
private DerivedValue createDerivedValue(DerivedRelationalState state) {
return getEntityBinding().getBaseTable().createDerivedValue( state.getFormula() );
}
private void initializeSingleValue(SingleValueRelationalState state) {
value = createSingleValue( state );
}
private SimpleValue createSingleValue(SingleValueRelationalState state) {
if ( state instanceof ColumnRelationalState ) {
return createColumn( ColumnRelationalState.class.cast( state ) );
}
else if ( state instanceof DerivedRelationalState ) {
return createDerivedValue( DerivedRelationalState.class.cast( state ) );
}
else {
throw new MappingException( "unknown relational state:" + state.getClass().getName() );
}
}
protected void initializeSimpleTupleValue(SimpleTupleRelationalState state) {
if ( state.getRelationalStates().size() == 0 ) {
throw new MappingException( "Tuple state does not contain any values." );
}
if ( state.getRelationalStates().size() == 1 ) {
initializeSingleValue( state.getRelationalStates().iterator().next() );
}
else {
value = createSimpleTupleValue( state );
}
}
private Tuple createSimpleTupleValue(SimpleTupleRelationalState state) {
Tuple tuple = getEntityBinding().getBaseTable().createTuple( "[" + getAttribute().getName() + "]" );
for ( SingleValueRelationalState singleValueState : state.getRelationalStates() ) {
tuple.addValue( createSingleValue( singleValueState ) );
}
return tuple;
TupleRelationalState tupleRelationalState = TupleRelationalState.class.cast( state );
return tupleRelationalState.getRelationalStates().size() == 1 ?
tupleRelationalState.getRelationalStates().get( 0 ) :
state;
}
@Override

View File

@ -111,37 +111,4 @@ public interface AttributeBinding {
public Set<EntityReferencingAttributeBinding> getEntityReferencingAttributeBindings();
public void validate();
// TODO: where should this RelationalState stuff go???
interface RelationalState {}
interface SingleValueRelationalState extends RelationalState {}
interface ColumnRelationalState extends SingleValueRelationalState {
NamingStrategy getNamingStrategy();
String getExplicitColumnName();
boolean isUnique();
Size getSize();
boolean isNullable();
String getCheckCondition();
String getDefault();
String getSqlType();
String getCustomWriteFragment();
String getCustomReadFragment();
String getComment();
Set<String> getUniqueKeys();
Set<String> getIndexes();
}
interface DerivedRelationalState extends SingleValueRelationalState {
String getFormula();
}
interface SimpleTupleRelationalState extends AbstractAttributeBinding.TupleRelationalState<SingleValueRelationalState> {
}
interface TupleRelationalState<T extends RelationalState> extends RelationalState{
List<T> getRelationalStates();
}
}

View File

@ -24,6 +24,7 @@
package org.hibernate.metamodel.binding;
import org.hibernate.metamodel.relational.Value;
import org.hibernate.metamodel.state.domain.CollectionElementDomainState;
/**
* TODO : javadoc
@ -31,10 +32,6 @@ import org.hibernate.metamodel.relational.Value;
* @author Steve Ebersole
*/
public class CollectionElement {
public static interface DomainState {
HibernateTypeDescriptor getHibernateTypeDescriptor();
String getNodeName();
}
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
private final PluralAttributeBinding collectionBinding;
@ -47,7 +44,7 @@ public class CollectionElement {
this.collectionBinding = collectionBinding;
}
public void initialize(DomainState state) {
public void initialize(CollectionElementDomainState state) {
hibernateTypeDescriptor.initialize( state.getHibernateTypeDescriptor() );
nodeName = state.getNodeName();
}

View File

@ -30,6 +30,8 @@ import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.metamodel.relational.ForeignKey;
import org.hibernate.metamodel.relational.SimpleValue;
import org.hibernate.metamodel.relational.Column;
import org.hibernate.metamodel.state.domain.ManyToOneAttributeDomainState;
import org.hibernate.metamodel.state.relational.ManyToOneRelationalState;
/**
* TODO : javadoc
@ -45,23 +47,11 @@ public class ManyToOneAttributeBinding extends SingularAttributeBinding implemen
private AttributeBinding referencedAttributeBinding;
private boolean ignoreNotFound;
public static interface DomainState extends SingularAttributeBinding.DomainState {
boolean isUnwrapProxy();
String getReferencedAttributeName();
String getReferencedEntityName();
boolean ignoreNotFound();
}
public static interface RelationalState extends AttributeBinding.RelationalState {
boolean isLogicalOneToOne();
String getForeignKeyName();
}
ManyToOneAttributeBinding(EntityBinding entityBinding) {
super( entityBinding, false, false );
}
public final void initialize(DomainState state) {
public final void initialize(ManyToOneAttributeDomainState state) {
super.initialize( state );
isPropertyReference = state.getReferencedAttributeName() != null;
referencedAttributeName = state.getReferencedAttributeName();
@ -75,8 +65,8 @@ public class ManyToOneAttributeBinding extends SingularAttributeBinding implemen
}
}
public final void initialize(RelationalState state) {
super.initialize( state );
public final void initialize(ManyToOneRelationalState state) {
super.initializeValue( state );
isLogicalOneToOne = state.isLogicalOneToOne();
foreignKeyName = state.getForeignKeyName();
}

View File

@ -26,19 +26,13 @@ package org.hibernate.metamodel.binding;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import org.dom4j.Attribute;
import org.dom4j.Element;
import org.jboss.logging.Logger;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.relational.Table;
import org.hibernate.metamodel.source.hbm.HbmHelper;
import org.hibernate.metamodel.source.util.DomHelper;
import org.hibernate.metamodel.state.domain.PluralAttributeDomainState;
/**
* TODO : javadoc
@ -47,35 +41,6 @@ import org.hibernate.metamodel.source.util.DomHelper;
*/
public abstract class PluralAttributeBinding extends AbstractAttributeBinding {
public static interface DomainState extends AbstractAttributeBinding.DomainState {
FetchMode getFetchMode();
boolean isExtraLazy();
CollectionElement getCollectionElement(PluralAttributeBinding binding);
boolean isInverse();
boolean isMutable();
boolean isSubselectLoadable();
String getCacheConcurrencyStrategy();
String getCacheRegionName();
String getOrderBy();
String getWhere();
String getReferencedPropertyName();
boolean isSorted();
Comparator getComparator();
String getComparatorClassName();
boolean isOrphanDelete();
int getBatchSize();
boolean isEmbedded();
boolean isOptimisticLocked();
Class getCollectionPersisterClass();
java.util.Map getFilters();
java.util.Set getSynchronizedTables();
CustomSQL getCustomSQLInsert();
CustomSQL getCustomSQLUpdate();
CustomSQL getCustomSQLDelete();
CustomSQL getCustomSQLDeleteAll();
String getLoaderName();
}
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, PluralAttributeBinding.class.getName()
);
@ -119,11 +84,12 @@ public abstract class PluralAttributeBinding extends AbstractAttributeBinding {
collectionElement = new CollectionElement( this );
}
public void initialize(DomainState state) {
public void initialize(PluralAttributeDomainState state) {
super.initialize( state );
fetchMode = state.getFetchMode();
extraLazy = state.isExtraLazy();
collectionElement = state.getCollectionElement( this );
collectionElement = new ElementCollectionElement( this );
collectionElement.initialize( state.getCollectionElementDomainState() );
inverse = state.isInverse();
mutable = state.isMutable();
subselectLoadable = state.isSubselectLoadable();
@ -152,8 +118,6 @@ public abstract class PluralAttributeBinding extends AbstractAttributeBinding {
loaderName = state.getLoaderName();
}
protected boolean isLazyDefault(MappingDefaults defaults) {
return defaults.isDefaultLazy();
}

View File

@ -24,6 +24,10 @@
package org.hibernate.metamodel.binding;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.state.domain.SimpleAttributeDomainState;
import org.hibernate.metamodel.state.relational.ColumnRelationalState;
import org.hibernate.metamodel.state.relational.DerivedValueRelationalState;
import org.hibernate.metamodel.state.relational.TupleRelationalState;
/**
* TODO : javadoc
@ -31,31 +35,27 @@ import org.hibernate.mapping.PropertyGeneration;
* @author Steve Ebersole
*/
public class SimpleAttributeBinding extends SingularAttributeBinding {
public static interface DomainState extends SingularAttributeBinding.DomainState {
public PropertyGeneration getPropertyGeneration();
}
private PropertyGeneration generation;
SimpleAttributeBinding(EntityBinding entityBinding, boolean forceNonNullable, boolean forceUnique) {
super( entityBinding, forceNonNullable, forceUnique );
}
public final void initialize(DomainState state) {
public final void initialize(SimpleAttributeDomainState state) {
super.initialize( state );
generation = state.getPropertyGeneration();
}
public void initializeColumnValue(ColumnRelationalState state) {
super.initializeColumnValue( state );
super.initializeValue( state );
}
public void initializeDerivedValue(DerivedRelationalState state) {
super.initializeDerivedValue( state );
public void initializeDerivedValue(DerivedValueRelationalState state) {
super.initializeValue( state );
}
public void initializeSimpleTupleValue(SimpleTupleRelationalState state) {
super.initializeSimpleTupleValue( state );
public void initializeTupleValue(TupleRelationalState state) {
super.initializeValue( state );
}
private boolean isUnique(ColumnRelationalState state) {

View File

@ -23,19 +23,14 @@
*/
package org.hibernate.metamodel.binding;
import org.hibernate.metamodel.state.domain.SingularAttributeDomainState;
/**
* TODO : javadoc
*
* @author Gail Badner
*/
public abstract class SingularAttributeBinding extends AbstractAttributeBinding implements KeyValueBinding {
public static interface DomainState extends AbstractAttributeBinding.DomainState {
boolean isInsertable();
boolean isUpdateable();
boolean isKeyCasadeDeleteEnabled();
String getUnsavedValue();
}
private final boolean forceNonNullable;
private final boolean forceUnique;
private boolean insertable;
@ -49,7 +44,7 @@ public abstract class SingularAttributeBinding extends AbstractAttributeBinding
this.forceUnique = forceUnique;
}
public final void initialize(DomainState state) {
public final void initialize(SingularAttributeDomainState state) {
super.initialize( state );
insertable = state.isInsertable();
updateable = state.isUpdateable();

View File

@ -26,7 +26,7 @@ package org.hibernate.metamodel.relational;
import java.util.Set;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.state.relational.ColumnRelationalState;
/**
* Models a physical column
@ -55,6 +55,26 @@ public class Column extends AbstractSimpleValue implements SimpleValue {
this.name = name;
}
public void initialize(ColumnRelationalState state, boolean forceNonNullable, boolean forceUnique) {
size.initialize( state.getSize() );
nullable = ! forceNonNullable && state.isNullable();
unique = ! forceUnique && state.isUnique();
checkCondition = state.getCheckCondition();
defaultValue = state.getDefault();
sqlType = state.getSqlType();
// TODO: this should go into binding instead (I think???)
writeFragment = state.getCustomWriteFragment();
readFragment = state.getCustomReadFragment();
comment = state.getComment();
for ( String uniqueKey : state.getUniqueKeys() ) {
getTable().getOrCreateUniqueKey( uniqueKey ).addColumn( this );
}
for ( String index : state.getIndexes() ) {
getTable().getOrCreateIndex( index ).addColumn( this );
}
}
public String getName() {
return name;
}
@ -135,5 +155,4 @@ public class Column extends AbstractSimpleValue implements SimpleValue {
public String toLoggableString() {
return getTable().getLoggableValueQualifier() + '.' + getName();
}
}

View File

@ -75,4 +75,5 @@ public interface Value {
* @throws org.hibernate.metamodel.ValidationException if validaton fails.
*/
public void validateJdbcTypes(JdbcCodes typeCodes);
}

View File

@ -0,0 +1,126 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.relational;
import org.hibernate.MappingException;
import org.hibernate.metamodel.state.relational.ColumnRelationalState;
import org.hibernate.metamodel.state.relational.DerivedValueRelationalState;
import org.hibernate.metamodel.state.relational.ValueRelationalState;
import org.hibernate.metamodel.state.relational.SimpleValueRelationalState;
import org.hibernate.metamodel.state.relational.TupleRelationalState;
/**
* @author Gail Badner
*/
public class ValueFactory {
public static Column createColumn(TableSpecification table,
String attributeName,
ColumnRelationalState state,
boolean forceNonNullable,
boolean forceUnique
) {
final String explicitName = state.getExplicitColumnName();
final String logicalColumnName = state.getNamingStrategy().logicalColumnName( explicitName, attributeName );
final String columnName =
explicitName == null ?
state.getNamingStrategy().propertyToColumnName( attributeName ) :
state.getNamingStrategy().columnName( explicitName );
// todo : find out the purpose of these logical bindings
// mappings.addColumnBinding( logicalColumnName, column, table );
if ( columnName == null ) {
throw new IllegalArgumentException( "columnName must be non-null." );
}
Column value = table.createColumn( columnName );
value.initialize( state, forceNonNullable, forceUnique );
return value;
}
public static DerivedValue createDerivedValue(TableSpecification table,
DerivedValueRelationalState state) {
return table.createDerivedValue( state.getFormula() );
}
public static SimpleValue createSimpleValue(TableSpecification table,
String attributeName,
SimpleValueRelationalState state,
boolean forceNonNullable,
boolean forceUnique
) {
if ( state instanceof ColumnRelationalState ) {
ColumnRelationalState columnRelationalState = ColumnRelationalState.class.cast( state );
return createColumn( table, attributeName, columnRelationalState, forceNonNullable, forceUnique );
}
else if ( state instanceof DerivedValueRelationalState ) {
return createDerivedValue( table, DerivedValueRelationalState.class.cast( state ) );
}
else {
throw new MappingException( "unknown relational state:" + state.getClass().getName() );
}
}
public static Tuple createTuple(TableSpecification table,
String attributeName,
TupleRelationalState state,
boolean forceNonNullable,
boolean forceUnique
) {
Tuple tuple = table.createTuple( "[" + attributeName + "]" );
for ( SimpleValueRelationalState valueState : state.getRelationalStates() ) {
tuple.addValue( createSimpleValue( table, attributeName, valueState, forceNonNullable, forceUnique ) );
}
return tuple;
}
public static Value createValue(TableSpecification table,
String attributeName,
ValueRelationalState state,
boolean forceNonNullable,
boolean forceUnique) {
Value value = null;
if ( SimpleValueRelationalState.class.isInstance( state ) ) {
value = createSimpleValue(
table,
attributeName,
SimpleValueRelationalState.class.cast( state ),
forceNonNullable,
forceUnique
);
}
else if ( TupleRelationalState.class.isInstance( state ) ) {
value = createTuple(
table,
attributeName,
TupleRelationalState.class.cast( state ),
forceNonNullable,
forceUnique
);
}
else {
throw new MappingException( "Unexpected type of RelationalState" + state.getClass().getName() );
}
return value;
}
}

View File

@ -213,7 +213,7 @@ public class EntityBinder {
AttributeColumnRelationalState columnRelationsState = new AttributeColumnRelationalState( idAttribute, meta );
AttributeTupleRelationalState relationalState = new AttributeTupleRelationalState();
relationalState.addValueState( columnRelationsState );
idBinding.initializeSimpleTupleValue( relationalState );
idBinding.initializeTupleValue( relationalState );
}
private void bindAttributes(EntityBinding entityBinding) {
@ -241,7 +241,7 @@ public class EntityBinder {
);
AttributeTupleRelationalState relationalState = new AttributeTupleRelationalState();
relationalState.addValueState( columnRelationsState );
attributeBinding.initializeSimpleTupleValue( relationalState );
attributeBinding.initializeTupleValue( relationalState );
}
}

View File

@ -5,16 +5,16 @@ import java.util.Map;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.binding.EntityBinding;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.domain.Attribute;
import org.hibernate.metamodel.domain.Entity;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.state.domain.SimpleAttributeDomainState;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
/**
* @author Hardy Ferentschik
*/
public class AttributeDomainState implements SimpleAttributeBinding.DomainState {
public class AttributeDomainState implements SimpleAttributeDomainState {
private final PropertyGeneration propertyGeneration = null;
private final HibernateTypeDescriptor typeDescriptor;
private final Attribute attribute;
@ -101,7 +101,7 @@ public class AttributeDomainState implements SimpleAttributeBinding.DomainState
}
@Override
public Map<String, MetaAttribute> getMetaAttributes(EntityBinding entityBinding) {
public Map<String, MetaAttribute> getMetaAttributes() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
}

View File

@ -33,17 +33,18 @@ import org.jboss.jandex.AnnotationInstance;
import org.hibernate.AnnotationException;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.relational.Column;
import org.hibernate.metamodel.relational.Size;
import org.hibernate.metamodel.source.annotations.ColumnValues;
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
import org.hibernate.metamodel.source.internal.MetadataImpl;
import org.hibernate.metamodel.state.relational.ColumnRelationalState;
/**
* @author Hardy Ferentschik
*/
public class AttributeColumnRelationalState implements SimpleAttributeBinding.ColumnRelationalState {
public class AttributeColumnRelationalState implements ColumnRelationalState {
private final NamingStrategy namingStrategy;
private final String columnName;
private final boolean unique;

View File

@ -26,21 +26,21 @@ package org.hibernate.metamodel.source.annotations.state.relational;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.binding.AttributeBinding;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.state.relational.SimpleValueRelationalState;
import org.hibernate.metamodel.state.relational.TupleRelationalState;
/**
* @author Hardy Ferentschik
*/
public class AttributeTupleRelationalState implements SimpleAttributeBinding.SimpleTupleRelationalState {
List<AttributeBinding.SingleValueRelationalState> valueStates = new ArrayList<AttributeBinding.SingleValueRelationalState>();
public class AttributeTupleRelationalState implements TupleRelationalState {
List<SimpleValueRelationalState> valueStates = new ArrayList<SimpleValueRelationalState>();
public void addValueState(AttributeBinding.SingleValueRelationalState state) {
public void addValueState(SimpleValueRelationalState state) {
valueStates.add( state );
}
@Override
public List<AttributeBinding.SingleValueRelationalState> getRelationalStates() {
public List<SimpleValueRelationalState> getRelationalStates() {
return valueStates;
}
}

View File

@ -435,7 +435,7 @@ PrimitiveArray
if ( attributeBinding.getValue() == null ) {
// relational model has not been bound yet
// boolean (true here) indicates that by default column names should be guessed
attributeBinding.initializeSimpleTupleValue(
attributeBinding.initializeTupleValue(
new HbmSimpleValueRelationalStateContainer(
getHibernateMappingBinder(),
true,
@ -463,7 +463,7 @@ PrimitiveArray
if ( attributeBinding.getValue() == null ) {
// relational model has not been bound yet
// boolean (true here) indicates that by default column names should be guessed
attributeBinding.initializeSimpleTupleValue(
attributeBinding.initializeTupleValue(
new HbmSimpleValueRelationalStateContainer(
getHibernateMappingBinder(),
true,
@ -491,7 +491,7 @@ PrimitiveArray
if ( attributeBinding.getValue() == null ) {
// relational model has not been bound yet
// boolean (true here) indicates that by default column names should be guessed
attributeBinding.initializeSimpleTupleValue(
attributeBinding.initializeTupleValue(
new HbmSimpleValueRelationalStateContainer(
getHibernateMappingBinder(),
true,
@ -519,7 +519,7 @@ PrimitiveArray
if ( attributeBinding.getValue() == null ) {
// relational model has not been bound yet
// boolean (true here) indicates that by default column names should be guessed
attributeBinding.initializeSimpleTupleValue(
attributeBinding.initializeTupleValue(
new HbmSimpleValueRelationalStateContainer(
getHibernateMappingBinder(),
true,
@ -546,7 +546,7 @@ PrimitiveArray
if ( attributeBinding.getValue() == null ) {
// relational model has not been bound yet
// boolean (true here) indicates that by default column names should be guessed
attributeBinding.initializeSimpleTupleValue(
attributeBinding.initializeTupleValue(
new HbmSimpleValueRelationalStateContainer(
getHibernateMappingBinder(),
true,

View File

@ -25,17 +25,16 @@ package org.hibernate.metamodel.source.hbm.state.domain;
import java.util.Map;
import org.hibernate.metamodel.binding.AbstractAttributeBinding;
import org.hibernate.metamodel.binding.EntityBinding;
import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.domain.Attribute;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.util.MappingHelper;
import org.hibernate.metamodel.state.domain.AttributeDomainState;
/**
* @author Gail Badner
*/
public abstract class AbstractHbmAttributeDomainState implements AbstractAttributeBinding.DomainState {
public abstract class AbstractHbmAttributeDomainState implements AttributeDomainState {
private final MappingDefaults defaults;
private final Attribute attribute;
private final String nodeName;
@ -78,7 +77,7 @@ public abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
return nodeName;
}
public final Map<String, MetaAttribute> getMetaAttributes(EntityBinding entityBinding) {
public final Map<String, MetaAttribute> getMetaAttributes() {
return metaAttributes;
}
}

View File

@ -26,11 +26,12 @@ package org.hibernate.metamodel.source.hbm.state.domain;
import org.hibernate.metamodel.binding.CollectionElement;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLElementElement;
import org.hibernate.metamodel.state.domain.CollectionElementDomainState;
/**
* @author Gail Badner
*/
public class HbmCollectionElementDomainState implements CollectionElement.DomainState {
public class HbmCollectionElementDomainState implements CollectionElementDomainState {
private final XMLElementElement element;
HbmCollectionElementDomainState(XMLElementElement element) {

View File

@ -33,13 +33,14 @@ import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.hbm.HbmHelper;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
import org.hibernate.metamodel.source.util.MappingHelper;
import org.hibernate.metamodel.state.domain.ManyToOneAttributeDomainState;
/**
* @author Gail Badner
*/
public class HbmManyToOneAttributeDomainState
extends AbstractHbmAttributeDomainState
implements ManyToOneAttributeBinding.DomainState {
implements ManyToOneAttributeDomainState {
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
private final FetchMode fetchMode;

View File

@ -30,12 +30,10 @@ import java.util.Map;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
import org.hibernate.metamodel.binding.CollectionElement;
import org.hibernate.metamodel.binding.CustomSQL;
import org.hibernate.metamodel.binding.ElementCollectionElement;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.binding.PluralAttributeBinding;
import org.hibernate.metamodel.domain.Attribute;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.hbm.HbmHelper;
@ -47,12 +45,14 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdateElement;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronizeElement;
import org.hibernate.metamodel.source.util.MappingHelper;
import org.hibernate.metamodel.state.domain.CollectionElementDomainState;
import org.hibernate.metamodel.state.domain.PluralAttributeDomainState;
/**
* @author Gail Badner
*/
public class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainState implements PluralAttributeBinding.DomainState {
public class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainState implements PluralAttributeDomainState {
private final XMLBagElement collection;
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
private final String cascade;
@ -121,10 +121,8 @@ public class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainSta
return ( "extra".equals( collection.getLazy() ) );
}
public CollectionElement getCollectionElement(PluralAttributeBinding binding) {
ElementCollectionElement collectionElement = new ElementCollectionElement( binding );
collectionElement.initialize( new HbmCollectionElementDomainState( collection.getElement() ) );
return collectionElement;
public CollectionElementDomainState getCollectionElementDomainState() {
return new HbmCollectionElementDomainState( collection.getElement() );
}
public boolean isInverse() {

View File

@ -29,7 +29,6 @@ import org.hibernate.MappingException;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.hbm.HbmHelper;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLDiscriminator;
@ -38,11 +37,12 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLCla
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLVersion;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLPropertyElement;
import org.hibernate.metamodel.source.util.MappingHelper;
import org.hibernate.metamodel.state.domain.SimpleAttributeDomainState;
/**
* @author Gail Badner
*/
public class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainState implements SimpleAttributeBinding.DomainState {
public class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainState implements SimpleAttributeDomainState {
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
private final boolean isLazy;
private final PropertyGeneration propertyGeneration;

View File

@ -27,7 +27,6 @@ import java.util.Set;
import org.hibernate.MappingException;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.binding.AbstractAttributeBinding;
import org.hibernate.metamodel.relational.Size;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLDiscriminator;
@ -37,13 +36,14 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLCla
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLPropertyElement;
import org.hibernate.metamodel.source.util.MappingHelper;
import org.hibernate.metamodel.state.relational.ColumnRelationalState;
// TODO: remove duplication after Id, Discriminator, Version, Timestamp, and Property extend a common interface.
/**
* @author Gail Badner
*/
public class HbmColumnRelationalState implements AbstractAttributeBinding.ColumnRelationalState {
public class HbmColumnRelationalState implements ColumnRelationalState {
private final HbmSimpleValueRelationalStateContainer container;
private final String explicitColumnName;
private final Size size;

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.metamodel.source.hbm.state.relational;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.state.relational.DerivedValueRelationalState;
/**
* @author Gail Badner
*/
public class HbmDerivedValueRelationalState implements SimpleAttributeBinding.DerivedRelationalState {
public class HbmDerivedValueRelationalState implements DerivedValueRelationalState {
private final String formula;
public HbmDerivedValueRelationalState(String formula) {

View File

@ -23,15 +23,15 @@
*/
package org.hibernate.metamodel.source.hbm.state.relational;
import org.hibernate.metamodel.binding.ManyToOneAttributeBinding;
import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
import org.hibernate.metamodel.state.relational.ManyToOneRelationalState;
/**
* @author Gail Badner
*/
public class HbmManyToOneRelationalStateContainer extends HbmSimpleValueRelationalStateContainer
implements ManyToOneAttributeBinding.RelationalState {
implements ManyToOneRelationalState {
private final boolean isLogicalOneToOne;
private final String foreignKeyName;

View File

@ -25,17 +25,13 @@ package org.hibernate.metamodel.source.hbm.state.relational;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import org.hibernate.MappingException;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.binding.AbstractAttributeBinding;
import org.hibernate.metamodel.binding.AttributeBinding;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLDiscriminator;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLId;
@ -43,15 +39,17 @@ import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLCla
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLVersion;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLPropertyElement;
import org.hibernate.metamodel.state.relational.SimpleValueRelationalState;
import org.hibernate.metamodel.state.relational.TupleRelationalState;
/**
* @author Gail Badner
*/
public class HbmSimpleValueRelationalStateContainer implements AbstractAttributeBinding.SimpleTupleRelationalState {
public class HbmSimpleValueRelationalStateContainer implements TupleRelationalState {
private final MappingDefaults defaults;
private final Set<String> propertyUniqueKeys;
private final Set<String> propertyIndexes;
private final List<AttributeBinding.SingleValueRelationalState> singleValueStates;
private final List<SimpleValueRelationalState> simpleValueStates;
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
public NamingStrategy getNamingStrategy() {
@ -64,11 +62,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLId id) {
this( defaults, id.getColumn() );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( id.getColumn() == null && ! autoColumnCreation ) {
throw new MappingException( "No columns to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( id, this ) );
simpleValueStates.add( new HbmColumnRelationalState( id, this ) );
}
else if ( id.getColumn() != null ) {
throw new MappingException( "column attribute may not be used together with <column> subelement" );
@ -80,11 +78,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLDiscriminator discriminator) {
this( defaults, discriminator.getFormula(), discriminator.getColumn() );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( discriminator.getColumn() == null && discriminator.getFormula() == null && ! autoColumnCreation ) {
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( discriminator, this ) );
simpleValueStates.add( new HbmColumnRelationalState( discriminator, this ) );
}
else if ( discriminator.getColumn() != null || discriminator.getFormula() != null) {
throw new MappingException( "column/formula attribute may not be used together with <column>/<formula> subelement" );
@ -96,11 +94,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLVersion version) {
this( defaults, version.getColumn() );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( version.getColumn() == null && ! autoColumnCreation ) {
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( version, this ) );
simpleValueStates.add( new HbmColumnRelationalState( version, this ) );
}
else if ( version.getColumn() != null ) {
throw new MappingException( "column attribute may not be used together with <column> subelement" );
@ -112,11 +110,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLTimestamp timestamp) {
this( defaults, null );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( timestamp.getColumn() == null && ! autoColumnCreation ) {
throw new MappingException( "No columns to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( timestamp, this ) );
simpleValueStates.add( new HbmColumnRelationalState( timestamp, this ) );
}
else if ( timestamp.getColumn() != null ) {
throw new MappingException( "column attribute may not be used together with <column> subelement" );
@ -128,11 +126,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLPropertyElement property) {
this( defaults, property.getColumnOrFormula() );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( property.getColumn() == null && property.getFormula() == null && ! autoColumnCreation ) {
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( property, this ) );
simpleValueStates.add( new HbmColumnRelationalState( property, this ) );
}
else if ( property.getColumn() != null || property.getFormula() != null) {
throw new MappingException( "column/formula attribute may not be used together with <column>/<formula> subelement" );
@ -144,11 +142,11 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
boolean autoColumnCreation,
XMLManyToOneElement manyToOne) {
this( defaults, manyToOne.getColumnOrFormula() );
if ( singleValueStates.isEmpty() ) {
if ( simpleValueStates.isEmpty() ) {
if ( manyToOne.getColumn() == null && manyToOne.getFormula() == null && ! autoColumnCreation ) {
throw new MappingException( "No column or formula to map and auto column creation is disabled." );
}
singleValueStates.add( new HbmColumnRelationalState( manyToOne, this ) );
simpleValueStates.add( new HbmColumnRelationalState( manyToOne, this ) );
}
else if ( manyToOne.getColumn() != null || manyToOne.getFormula() != null) {
throw new MappingException( "column/formula attribute may not be used together with <column>/<formula> subelement" );
@ -171,19 +169,19 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
this.defaults = defaults;
this.propertyUniqueKeys = Collections.emptySet();
this.propertyIndexes = Collections.emptySet();
singleValueStates = new ArrayList<AttributeBinding.SingleValueRelationalState>(
simpleValueStates = new ArrayList<SimpleValueRelationalState>(
mappedColumnsOrFormulas == null || mappedColumnsOrFormulas.isEmpty() ?
1 :
mappedColumnsOrFormulas.size()
);
if ( mappedColumnsOrFormulas != null && ! mappedColumnsOrFormulas.isEmpty() ) {
for ( Object mappedColumnOrFormula : mappedColumnsOrFormulas ) {
singleValueStates.add( createColumnOrFormulaRelationalState( this, mappedColumnOrFormula ) );
simpleValueStates.add( createColumnOrFormulaRelationalState( this, mappedColumnOrFormula ) );
}
}
}
private static AttributeBinding.SingleValueRelationalState createColumnOrFormulaRelationalState(
private static SimpleValueRelationalState createColumnOrFormulaRelationalState(
HbmSimpleValueRelationalStateContainer container,
Object columnOrFormula) {
if ( XMLColumnElement.class.isInstance( columnOrFormula ) ) {
@ -198,8 +196,8 @@ public class HbmSimpleValueRelationalStateContainer implements AbstractAttribute
throw new MappingException( "unknown type of column or formula: " + columnOrFormula.getClass().getName() );
}
public List<AttributeBinding.SingleValueRelationalState> getRelationalStates() {
return singleValueStates;
public List<SimpleValueRelationalState> getRelationalStates() {
return simpleValueStates;
}
Set<String> getPropertyUniqueKeys() {

View File

@ -0,0 +1,45 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
import java.util.Map;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.domain.Attribute;
import org.hibernate.metamodel.domain.MetaAttribute;
/**
* @author Gail Badner
*/
public interface AttributeDomainState {
HibernateTypeDescriptor getHibernateTypeDescriptor();
Attribute getAttribute();
boolean isLazy();
String getPropertyAccessorName();
boolean isAlternateUniqueKey();
String getCascade();
boolean isOptimisticLockable();
String getNodeName();
Map<String, MetaAttribute> getMetaAttributes();
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
import org.hibernate.metamodel.binding.HibernateTypeDescriptor;
/**
* @author Gail Badner
*/
public interface CollectionElementDomainState {
HibernateTypeDescriptor getHibernateTypeDescriptor();
String getNodeName();
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
/**
* @author Gail Badner
*/
public interface ManyToOneAttributeDomainState extends SingularAttributeDomainState {
boolean isUnwrapProxy();
String getReferencedAttributeName();
String getReferencedEntityName();
boolean ignoreNotFound();
}

View File

@ -0,0 +1,68 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
import java.util.Comparator;
import org.hibernate.FetchMode;
import org.hibernate.metamodel.binding.AbstractAttributeBinding;
import org.hibernate.metamodel.binding.CollectionElement;
import org.hibernate.metamodel.binding.CustomSQL;
import org.hibernate.metamodel.binding.PluralAttributeBinding;
/**
* Created by IntelliJ IDEA.
* User: gbadner
* Date: 5/9/11
* Time: 4:49 PM
* To change this template use File | Settings | File Templates.
*/
public interface PluralAttributeDomainState extends AttributeDomainState {
FetchMode getFetchMode();
boolean isExtraLazy();
CollectionElementDomainState getCollectionElementDomainState();
boolean isInverse();
boolean isMutable();
boolean isSubselectLoadable();
String getCacheConcurrencyStrategy();
String getCacheRegionName();
String getOrderBy();
String getWhere();
String getReferencedPropertyName();
boolean isSorted();
Comparator getComparator();
String getComparatorClassName();
boolean isOrphanDelete();
int getBatchSize();
boolean isEmbedded();
boolean isOptimisticLocked();
Class getCollectionPersisterClass();
java.util.Map getFilters();
java.util.Set getSynchronizedTables();
CustomSQL getCustomSQLInsert();
CustomSQL getCustomSQLUpdate();
CustomSQL getCustomSQLDelete();
CustomSQL getCustomSQLDeleteAll();
String getLoaderName();
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.binding.SingularAttributeBinding;
/**
* @author Gail Badner
*/
public interface SimpleAttributeDomainState extends SingularAttributeDomainState {
public PropertyGeneration getPropertyGeneration();
}

View File

@ -0,0 +1,34 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.domain;
/**
* @author Gail Badner
*/
public interface SingularAttributeDomainState extends AttributeDomainState{
boolean isInsertable();
boolean isUpdateable();
boolean isKeyCasadeDeleteEnabled();
String getUnsavedValue();
}

View File

@ -0,0 +1,48 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
import java.util.Set;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.relational.Size;
/**
* @author Gail Badner
*/
public interface ColumnRelationalState extends SimpleValueRelationalState {
NamingStrategy getNamingStrategy();
String getExplicitColumnName();
boolean isUnique();
Size getSize();
boolean isNullable();
String getCheckCondition();
String getDefault();
String getSqlType();
String getCustomWriteFragment();
String getCustomReadFragment();
String getComment();
Set<String> getUniqueKeys();
Set<String> getIndexes();
}

View File

@ -0,0 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
import org.hibernate.metamodel.relational.SimpleValue;
/**
* Created by IntelliJ IDEA.
* User: gbadner
* Date: 5/9/11
* Time: 2:15 PM
* To change this template use File | Settings | File Templates.
*/
public interface DerivedValueRelationalState extends SimpleValueRelationalState {
String getFormula();
}

View File

@ -0,0 +1,32 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
/**
* @author Gail Badner
*/
public interface ManyToOneRelationalState extends ValueRelationalState {
boolean isLogicalOneToOne();
String getForeignKeyName();
}

View File

@ -0,0 +1,30 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
/**
* @author Gail Badner
*/
public interface SimpleValueRelationalState extends ValueRelationalState {
}

View File

@ -0,0 +1,33 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
import java.util.List;
/**
* @author Gail Badner
*/
public interface TupleRelationalState extends ValueRelationalState {
List<SimpleValueRelationalState> getRelationalStates();
}

View File

@ -0,0 +1,30 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, 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.state.relational;
/**
* @author Gail Badner
*/
public interface ValueRelationalState {
}