HHH-6480 - Develop component binding for new metamodel
This commit is contained in:
parent
605ce4ba29
commit
e540089783
|
@ -87,8 +87,8 @@ public class CacheDataDescriptionImpl implements CacheDataDescription {
|
|||
public static CacheDataDescriptionImpl decode(AbstractPluralAttributeBinding model) {
|
||||
return new CacheDataDescriptionImpl(
|
||||
model.isMutable(),
|
||||
model.getEntityBinding().isVersioned(),
|
||||
getVersionComparator( model.getEntityBinding() )
|
||||
model.getContainer().seekEntityBinding().isVersioned(),
|
||||
getVersionComparator( model.getContainer().seekEntityBinding() )
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.hibernate.metamodel.source.MetaAttributeContext;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAttributeBinding implements AttributeBinding {
|
||||
private final EntityBinding entityBinding;
|
||||
private final AttributeBindingContainer container;
|
||||
private final Attribute attribute;
|
||||
|
||||
private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor();
|
||||
|
@ -50,14 +50,14 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
|||
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
protected AbstractAttributeBinding(EntityBinding entityBinding, Attribute attribute) {
|
||||
this.entityBinding = entityBinding;
|
||||
protected AbstractAttributeBinding(AttributeBindingContainer container, Attribute attribute) {
|
||||
this.container = container;
|
||||
this.attribute = attribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityBinding getEntityBinding() {
|
||||
return entityBinding;
|
||||
public AttributeBindingContainer getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,18 +93,6 @@ public abstract class AbstractAttributeBinding implements AttributeBinding {
|
|||
this.includedInOptimisticLocking = includedInOptimisticLocking;
|
||||
}
|
||||
|
||||
protected boolean forceNonNullable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean forceUnique() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected final boolean isPrimaryKey() {
|
||||
return this == getEntityBinding().getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
/*
|
||||
* 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.binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractAttributeBindingContainer implements AttributeBindingContainer {
|
||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||
|
||||
protected void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
attributeBindingMap.put( name, attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute) {
|
||||
return makeSimpleAttributeBinding( attribute, false, false );
|
||||
}
|
||||
|
||||
private SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute, boolean forceNonNullable, boolean forceUnique) {
|
||||
final SimpleSingularAttributeBinding binding = new SimpleSingularAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
forceNonNullable,
|
||||
forceUnique
|
||||
);
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute) {
|
||||
final ComponentAttributeBinding binding = new ComponentAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature) {
|
||||
final BagBinding binding = new BagBinding( this, attribute, nature );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeBinding locateAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeBinding> attributeBindings() {
|
||||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The number of attribute bindings
|
||||
*/
|
||||
public int getAttributeBindingClosureSpan() {
|
||||
// TODO: fix this after HHH-6337 is fixed; for now just return size of attributeBindingMap
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindingMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The attribute bindings.
|
||||
*/
|
||||
public Iterable<AttributeBinding> getAttributeBindingClosure() {
|
||||
// TODO: fix this after HHH-6337 is fixed. for now, just return attributeBindings
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindings();
|
||||
}
|
||||
}
|
|
@ -77,10 +77,10 @@ public abstract class AbstractPluralAttributeBinding extends AbstractAttributeBi
|
|||
private String loaderName;
|
||||
|
||||
protected AbstractPluralAttributeBinding(
|
||||
EntityBinding entityBinding,
|
||||
AttributeBindingContainer container,
|
||||
PluralAttribute attribute,
|
||||
CollectionElementNature collectionElementNature) {
|
||||
super( entityBinding, attribute );
|
||||
super( container, attribute );
|
||||
this.collectionElement = interpretNature( collectionElementNature );
|
||||
}
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ public abstract class AbstractSingularAttributeBinding
|
|||
private boolean hasDerivedValue;
|
||||
private boolean isNullable = true;
|
||||
|
||||
protected AbstractSingularAttributeBinding(EntityBinding entityBinding, SingularAttribute attribute) {
|
||||
super( entityBinding, attribute );
|
||||
protected AbstractSingularAttributeBinding(AttributeBindingContainer container, SingularAttribute attribute) {
|
||||
super( container, attribute );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +79,7 @@ public abstract class AbstractSingularAttributeBinding
|
|||
}
|
||||
|
||||
private String getRole() {
|
||||
return getEntityBinding().getEntity().getName() + '.' + getAttribute().getName();
|
||||
return getContainer().getPathBase() + '.' + getAttribute().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,7 +88,7 @@ public abstract class AbstractSingularAttributeBinding
|
|||
return simpleValueBindings.size();
|
||||
}
|
||||
|
||||
private void checkValueBinding() {
|
||||
protected void checkValueBinding() {
|
||||
if ( value == null ) {
|
||||
throw new AssertionFailure( "No values yet bound!" );
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public interface AttributeBinding {
|
|||
*
|
||||
* @return The entity binding.
|
||||
*/
|
||||
public EntityBinding getEntityBinding();
|
||||
public AttributeBindingContainer getContainer();
|
||||
|
||||
/**
|
||||
* Obtain the attribute bound.
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* 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.binding;
|
||||
|
||||
import org.hibernate.metamodel.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AttributeBindingContainer {
|
||||
public String getPathBase();
|
||||
|
||||
public AttributeContainer getAttributeContainer();
|
||||
|
||||
public Iterable<AttributeBinding> attributeBindings();
|
||||
|
||||
public AttributeBinding locateAttributeBinding(String name);
|
||||
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute);
|
||||
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature);
|
||||
|
||||
public EntityBinding seekEntityBinding();
|
||||
|
||||
public TableSpecification getPrimaryTable();
|
||||
|
||||
public TableSpecification locateTable(String containingTableName);
|
||||
|
||||
public Class<?> getClassReference();
|
||||
|
||||
public MetaAttributeContext getMetaAttributeContext();
|
||||
}
|
|
@ -31,7 +31,7 @@ import org.hibernate.metamodel.domain.PluralAttribute;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BagBinding extends AbstractPluralAttributeBinding {
|
||||
protected BagBinding(EntityBinding entityBinding, PluralAttribute attribute, CollectionElementNature nature) {
|
||||
super( entityBinding, attribute, nature );
|
||||
protected BagBinding(AttributeBindingContainer container, PluralAttribute attribute, CollectionElementNature nature) {
|
||||
super( container, attribute, nature );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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.binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.domain.Component;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ComponentAttributeBinding extends AbstractSingularAttributeBinding implements AttributeBindingContainer {
|
||||
private final String path;
|
||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||
|
||||
private SingularAttribute parentReference;
|
||||
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
public ComponentAttributeBinding(AttributeBindingContainer container, SingularAttribute attribute) {
|
||||
super( container, attribute );
|
||||
this.path = container.getPathBase() + '.' + attribute.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityBinding seekEntityBinding() {
|
||||
return getContainer().seekEntityBinding();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPathBase() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeContainer getAttributeContainer() {
|
||||
return getComponent();
|
||||
}
|
||||
|
||||
public Component getComponent() {
|
||||
return (Component) getAttribute().getSingularAttributeType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAssociation() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
public void setMetaAttributeContext(MetaAttributeContext metaAttributeContext) {
|
||||
this.metaAttributeContext = metaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableSpecification getPrimaryTable() {
|
||||
return getContainer().getPrimaryTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableSpecification locateTable(String containingTableName) {
|
||||
return getContainer().locateTable( containingTableName );
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeBinding locateAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeBinding> attributeBindings() {
|
||||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkValueBinding() {
|
||||
// do nothing here...
|
||||
}
|
||||
|
||||
@Override
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute) {
|
||||
final SimpleSingularAttributeBinding binding = new SimpleSingularAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
isNullable(),
|
||||
isAlternateUniqueKey() // todo : is this accurate?
|
||||
);
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
protected void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
// todo : hook this into the EntityBinding notion of "entity referencing attribute bindings"
|
||||
attributeBindingMap.put( name, attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentAttributeBinding makeComponentAttributeBinding(SingularAttribute attribute) {
|
||||
final ComponentAttributeBinding binding = new ComponentAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature) {
|
||||
final BagBinding binding = new BagBinding( this, attribute, nature );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
return getComponent().getClassReference();
|
||||
}
|
||||
|
||||
public SingularAttribute getParentReference() {
|
||||
return parentReference;
|
||||
}
|
||||
|
||||
public void setParentReference(SingularAttribute parentReference) {
|
||||
this.parentReference = parentReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyGeneration getGeneration() {
|
||||
// todo : not sure the correct thing to return here since it essentially relies on the simple sub-attributes.
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -32,9 +32,8 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.engine.spi.FilterDefinition;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.domain.AttributeContainer;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
import org.hibernate.metamodel.relational.TableSpecification;
|
||||
import org.hibernate.metamodel.source.MetaAttributeContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
@ -47,7 +46,7 @@ import org.hibernate.tuple.entity.EntityTuplizer;
|
|||
* @author Hardy Ferentschik
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class EntityBinding {
|
||||
public class EntityBinding extends AbstractAttributeBindingContainer {
|
||||
private final EntityBinding superEntityBinding;
|
||||
private final HierarchyDetails hierarchyDetails;
|
||||
|
||||
|
@ -64,12 +63,9 @@ public class EntityBinding {
|
|||
|
||||
private String discriminatorMatchValue;
|
||||
|
||||
private Map<String, AttributeBinding> attributeBindingMap = new HashMap<String, AttributeBinding>();
|
||||
|
||||
private Set<FilterDefinition> filterDefinitions = new HashSet<FilterDefinition>();
|
||||
private Set<SingularAssociationAttributeBinding> entityReferencingAttributeBindings = new HashSet<SingularAssociationAttributeBinding>();
|
||||
|
||||
|
||||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
private boolean lazy;
|
||||
|
@ -135,7 +131,8 @@ public class EntityBinding {
|
|||
this.entity = entity;
|
||||
}
|
||||
|
||||
public TableSpecification getBaseTable() {
|
||||
@Override
|
||||
public TableSpecification getPrimaryTable() {
|
||||
return baseTable;
|
||||
}
|
||||
|
||||
|
@ -143,7 +140,7 @@ public class EntityBinding {
|
|||
this.baseTable = baseTable;
|
||||
}
|
||||
|
||||
public TableSpecification getTable(String tableName) {
|
||||
public TableSpecification locateTable(String tableName) {
|
||||
if ( tableName == null ) {
|
||||
return baseTable;
|
||||
}
|
||||
|
@ -171,40 +168,6 @@ public class EntityBinding {
|
|||
this.discriminatorMatchValue = discriminatorMatchValue;
|
||||
}
|
||||
|
||||
public Iterable<AttributeBinding> getAttributeBindings() {
|
||||
return attributeBindingMap.values();
|
||||
}
|
||||
|
||||
public AttributeBinding getAttributeBinding(String name) {
|
||||
return attributeBindingMap.get( name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the number of attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The number of attribute bindings
|
||||
*/
|
||||
public int getAttributeBindingClosureSpan() {
|
||||
// TODO: fix this after HHH-6337 is fixed; for now just return size of attributeBindingMap
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return attributeBindingMap.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute bindings defined on this class, including the
|
||||
* identifier attribute binding and attribute bindings defined
|
||||
* as part of a join.
|
||||
*
|
||||
* @return The attribute bindings.
|
||||
*/
|
||||
public Iterable<AttributeBinding> getAttributeBindingClosure() {
|
||||
// TODO: fix this after HHH-6337 is fixed. for now, just return attributeBindings
|
||||
// if this is not a root, then need to include the superclass attribute bindings
|
||||
return getAttributeBindings();
|
||||
}
|
||||
|
||||
public Iterable<FilterDefinition> getFilterDefinitions() {
|
||||
return filterDefinitions;
|
||||
}
|
||||
|
@ -217,42 +180,35 @@ public class EntityBinding {
|
|||
return entityReferencingAttributeBindings;
|
||||
}
|
||||
|
||||
public SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute) {
|
||||
return makeSimpleAttributeBinding( attribute, false, false );
|
||||
@Override
|
||||
public EntityBinding seekEntityBinding() {
|
||||
return this;
|
||||
}
|
||||
|
||||
private SimpleSingularAttributeBinding makeSimpleAttributeBinding(SingularAttribute attribute, boolean forceNonNullable, boolean forceUnique) {
|
||||
final SimpleSingularAttributeBinding binding = new SimpleSingularAttributeBinding(
|
||||
this,
|
||||
attribute,
|
||||
forceNonNullable,
|
||||
forceUnique
|
||||
);
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
@Override
|
||||
public String getPathBase() {
|
||||
return getEntity().getName();
|
||||
}
|
||||
|
||||
public ManyToOneAttributeBinding makeManyToOneAttributeBinding(SingularAttribute attribute) {
|
||||
final ManyToOneAttributeBinding binding = new ManyToOneAttributeBinding( this, attribute );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
@Override
|
||||
public Class<?> getClassReference() {
|
||||
return getEntity().getClassReference();
|
||||
}
|
||||
|
||||
public BagBinding makeBagAttributeBinding(PluralAttribute attribute, CollectionElementNature nature) {
|
||||
final BagBinding binding = new BagBinding( this, attribute, nature );
|
||||
registerAttributeBinding( attribute.getName(), binding );
|
||||
return binding;
|
||||
@Override
|
||||
public AttributeContainer getAttributeContainer() {
|
||||
return getEntity();
|
||||
}
|
||||
|
||||
private void registerAttributeBinding(String name, SingularAssociationAttributeBinding attributeBinding) {
|
||||
entityReferencingAttributeBindings.add( attributeBinding );
|
||||
registerAttributeBinding( name, (AttributeBinding) attributeBinding );
|
||||
}
|
||||
|
||||
private void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
attributeBindingMap.put( name, attributeBinding );
|
||||
@Override
|
||||
protected void registerAttributeBinding(String name, AttributeBinding attributeBinding) {
|
||||
if ( SingularAssociationAttributeBinding.class.isInstance( attributeBinding ) ) {
|
||||
entityReferencingAttributeBindings.add( (SingularAssociationAttributeBinding) attributeBinding );
|
||||
}
|
||||
super.registerAttributeBinding( name, attributeBinding );
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.metamodel.binding;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
|
@ -47,8 +48,8 @@ public class ManyToOneAttributeBinding extends SimpleSingularAttributeBinding im
|
|||
private CascadeStyle cascadeStyle;
|
||||
private FetchMode fetchMode;
|
||||
|
||||
ManyToOneAttributeBinding(EntityBinding entityBinding, SingularAttribute attribute) {
|
||||
super( entityBinding, attribute, false, false );
|
||||
ManyToOneAttributeBinding(AttributeBindingContainer container, SingularAttribute attribute) {
|
||||
super( container, attribute, false, false );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -124,10 +125,14 @@ public class ManyToOneAttributeBinding extends SimpleSingularAttributeBinding im
|
|||
|
||||
@Override
|
||||
public final void resolveReference(AttributeBinding referencedAttributeBinding) {
|
||||
if ( !referencedEntityName.equals( referencedAttributeBinding.getEntityBinding().getEntity().getName() ) ) {
|
||||
if ( ! EntityBinding.class.isInstance( referencedAttributeBinding.getContainer() ) ) {
|
||||
throw new AssertionFailure( "Illegal attempt to resolve many-to-one reference based on non-entity attribute" );
|
||||
}
|
||||
final EntityBinding entityBinding = (EntityBinding) referencedAttributeBinding.getContainer();
|
||||
if ( !referencedEntityName.equals( entityBinding.getEntity().getName() ) ) {
|
||||
throw new IllegalStateException(
|
||||
"attempt to set EntityBinding with name: [" +
|
||||
referencedAttributeBinding.getEntityBinding().getEntity().getName() +
|
||||
entityBinding.getEntity().getName() +
|
||||
"; entity name should be: " + referencedEntityName
|
||||
);
|
||||
}
|
||||
|
@ -154,7 +159,7 @@ public class ManyToOneAttributeBinding extends SimpleSingularAttributeBinding im
|
|||
|
||||
@Override
|
||||
public final EntityBinding getReferencedEntityBinding() {
|
||||
return referencedAttributeBinding.getEntityBinding();
|
||||
return (EntityBinding) referencedAttributeBinding.getContainer();
|
||||
}
|
||||
|
||||
// private void buildForeignKey() {
|
||||
|
|
|
@ -56,11 +56,11 @@ public class SimpleSingularAttributeBinding
|
|||
private MetaAttributeContext metaAttributeContext;
|
||||
|
||||
SimpleSingularAttributeBinding(
|
||||
EntityBinding entityBinding,
|
||||
AttributeBindingContainer container,
|
||||
SingularAttribute attribute,
|
||||
boolean forceNonNullable,
|
||||
boolean forceUnique) {
|
||||
super( entityBinding, attribute );
|
||||
super( container, attribute );
|
||||
this.forceNonNullable = forceNonNullable;
|
||||
this.forceUnique = forceUnique;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class SimpleSingularAttributeBinding
|
|||
// TODO: not sure how this works for collection IDs...
|
||||
//pass the entity-name, if not a collection-id
|
||||
//if ( rootClass!=null) {
|
||||
params.setProperty( IdentifierGenerator.ENTITY_NAME, getEntityBinding().getEntity().getName() );
|
||||
params.setProperty( IdentifierGenerator.ENTITY_NAME, getContainer().seekEntityBinding().getEntity().getName() );
|
||||
//}
|
||||
|
||||
//init the table here instead of earlier, so that we can get a quoted table name
|
||||
|
|
|
@ -112,7 +112,8 @@ public abstract class AbstractAttributeContainer implements AttributeContainer,
|
|||
|
||||
@Override
|
||||
public SingularAttribute createComponentAttribute(String name, Component component) {
|
||||
SingularAttributeImpl attribute = new SingularAttributeImpl( name, component );
|
||||
SingularAttributeImpl attribute = new SingularAttributeImpl( name, this );
|
||||
attribute.resolveType( component );
|
||||
addAttribute( attribute );
|
||||
return attribute;
|
||||
}
|
||||
|
|
|
@ -58,11 +58,13 @@ public class EntitySourceImpl implements EntitySource {
|
|||
private final EntityClass entityClass;
|
||||
private final Set<SubclassEntitySource> subclassEntitySources;
|
||||
private final Origin origin;
|
||||
private final LocalBindingContextImpl localBindingContext;
|
||||
|
||||
public EntitySourceImpl(EntityClass entityClass) {
|
||||
this.entityClass = entityClass;
|
||||
this.subclassEntitySources = new HashSet<SubclassEntitySource>();
|
||||
this.origin = new Origin( SourceType.ANNOTATION, entityClass.getName() );
|
||||
this.localBindingContext = new LocalBindingContextImpl( entityClass.getContext() );
|
||||
}
|
||||
|
||||
public EntityClass getEntityClass() {
|
||||
|
@ -75,8 +77,8 @@ public class EntitySourceImpl implements EntitySource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LocalBindingContext getBindingContext() {
|
||||
return new LocalBindingContextImpl( entityClass.getContext() );
|
||||
public LocalBindingContext getLocalBindingContext() {
|
||||
return localBindingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,6 +176,11 @@ public class EntitySourceImpl implements EntitySource {
|
|||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return entityClass.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeSource> attributeSources() {
|
||||
List<AttributeSource> attributeList = new ArrayList<AttributeSource>();
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.source.binder;
|
||||
|
||||
import org.hibernate.metamodel.source.LocalBindingContext;
|
||||
|
||||
/**
|
||||
* Contract for a container of {@link AttributeSource} references. Both entities and components contain
|
||||
* attributes.
|
||||
|
@ -31,9 +33,23 @@ package org.hibernate.metamodel.source.binder;
|
|||
*/
|
||||
public interface AttributeSourceContainer {
|
||||
/**
|
||||
Obtain this container's attribute sources.
|
||||
* Obtain the path used to uniquely identify this container.
|
||||
*
|
||||
* @return TYhe attribute sources.
|
||||
* @return The unique identifier path
|
||||
*/
|
||||
public String getPath();
|
||||
|
||||
/**
|
||||
* Obtain this container's attribute sources.
|
||||
*
|
||||
* @return The attribute sources.
|
||||
*/
|
||||
public Iterable<AttributeSource> attributeSources();
|
||||
|
||||
/**
|
||||
* Obtain the local binding context associated with this container.
|
||||
*
|
||||
* @return The local binding context
|
||||
*/
|
||||
public LocalBindingContext getLocalBindingContext();
|
||||
}
|
||||
|
|
|
@ -34,10 +34,11 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.beans.BeanInfoHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.binding.AbstractPluralAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.AttributeBindingContainer;
|
||||
import org.hibernate.metamodel.binding.CollectionElementNature;
|
||||
import org.hibernate.metamodel.binding.ComponentAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.EntityDiscriminator;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
|
@ -48,6 +49,7 @@ import org.hibernate.metamodel.binding.SimpleValueBinding;
|
|||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.binding.TypeDef;
|
||||
import org.hibernate.metamodel.domain.Attribute;
|
||||
import org.hibernate.metamodel.domain.Component;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.PluralAttribute;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
|
@ -116,7 +118,7 @@ public class Binder {
|
|||
return metadata.getEntityBinding( entitySource.getEntityName() );
|
||||
}
|
||||
|
||||
currentBindingContext = entitySource.getBindingContext();
|
||||
currentBindingContext = entitySource.getLocalBindingContext();
|
||||
try {
|
||||
final EntityBinding entityBinding = doCreateEntityBinding( entitySource, superEntityBinding );
|
||||
|
||||
|
@ -266,7 +268,7 @@ public class Binder {
|
|||
private EntityBinding makeDiscriminatedSubclassBinding(SubclassEntitySource entitySource, EntityBinding superEntityBinding) {
|
||||
final EntityBinding entityBinding = buildBasicEntityBinding( entitySource, superEntityBinding );
|
||||
|
||||
entityBinding.setBaseTable( superEntityBinding.getBaseTable() );
|
||||
entityBinding.setBaseTable( superEntityBinding.getPrimaryTable() );
|
||||
|
||||
bindDiscriminatorValue( entitySource, entityBinding );
|
||||
|
||||
|
@ -332,12 +334,12 @@ public class Binder {
|
|||
// this should never ever happen..
|
||||
throw new AssertionFailure( "Simple-id was not a column." );
|
||||
}
|
||||
entityBinding.getBaseTable().getPrimaryKey().addColumn( Column.class.cast( relationalValue ) );
|
||||
entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( relationalValue ) );
|
||||
}
|
||||
else {
|
||||
for ( SimpleValue subValue : ( (Tuple) relationalValue ).values() ) {
|
||||
if ( Column.class.isInstance( subValue ) ) {
|
||||
entityBinding.getBaseTable().getPrimaryKey().addColumn( Column.class.cast( subValue ) );
|
||||
entityBinding.getPrimaryTable().getPrimaryKey().addColumn( Column.class.cast( subValue ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -388,7 +390,7 @@ public class Binder {
|
|||
entityBinding.setDiscriminatorMatchValue( discriminatorValue );
|
||||
}
|
||||
|
||||
private void bindAttributes(AttributeSourceContainer attributeSourceContainer, EntityBinding entityBinding) {
|
||||
private void bindAttributes(AttributeSourceContainer attributeSourceContainer, AttributeBindingContainer attributeBindingContainer) {
|
||||
// todo : we really need the notion of a Stack here for the table from which the columns come for binding these attributes.
|
||||
// todo : adding the concept (interface) of a source of attribute metadata would allow reuse of this method for entity, component, unique-key, etc
|
||||
// for now, simply assume all columns come from the base table....
|
||||
|
@ -397,32 +399,54 @@ public class Binder {
|
|||
if ( attributeSource.isSingular() ) {
|
||||
final SingularAttributeSource singularAttributeSource = (SingularAttributeSource) attributeSource;
|
||||
if ( singularAttributeSource.getNature() == SingularAttributeNature.COMPONENT ) {
|
||||
bindComponent( singularAttributeSource, entityBinding );
|
||||
bindComponent( (ComponentAttributeSource) singularAttributeSource, attributeBindingContainer );
|
||||
}
|
||||
else {
|
||||
doBasicSingularAttributeBindingCreation( singularAttributeSource, entityBinding );
|
||||
doBasicSingularAttributeBindingCreation( singularAttributeSource, attributeBindingContainer );
|
||||
}
|
||||
}
|
||||
else {
|
||||
bindPersistentCollection( (PluralAttributeSource) attributeSource, entityBinding );
|
||||
bindPersistentCollection( (PluralAttributeSource) attributeSource, attributeBindingContainer );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bindComponent(SingularAttributeSource singularAttributeSource, EntityBinding entityBinding) {
|
||||
throw new NotYetImplementedException( "Component binding not yet implemented :(" );
|
||||
private void bindComponent(ComponentAttributeSource attributeSource, AttributeBindingContainer container) {
|
||||
final String attributeName = attributeSource.getName();
|
||||
SingularAttribute attribute = container.getAttributeContainer().locateComponentAttribute( attributeName );
|
||||
if ( attribute == null ) {
|
||||
final Component component = new Component(
|
||||
attributeSource.getPath(),
|
||||
attributeSource.getClassName(),
|
||||
attributeSource.getClassReference(),
|
||||
null // component inheritance not YET supported
|
||||
);
|
||||
attribute = container.getAttributeContainer().createComponentAttribute( attributeName, component );
|
||||
}
|
||||
ComponentAttributeBinding componentAttributeBinding = container.makeComponentAttributeBinding( attribute );
|
||||
|
||||
if ( StringHelper.isNotEmpty( attributeSource.getParentReferenceAttributeName() ) ) {
|
||||
final SingularAttribute parentReferenceAttribute =
|
||||
componentAttributeBinding.getComponent().createSingularAttribute( attributeSource.getParentReferenceAttributeName() );
|
||||
componentAttributeBinding.setParentReference( parentReferenceAttribute );
|
||||
}
|
||||
|
||||
private void bindPersistentCollection(PluralAttributeSource attributeSource, EntityBinding entityBinding) {
|
||||
final PluralAttribute existingAttribute = entityBinding.getEntity()
|
||||
.locatePluralAttribute( attributeSource.getName() );
|
||||
componentAttributeBinding.setMetaAttributeContext(
|
||||
buildMetaAttributeContext( attributeSource.metaAttributes(), container.getMetaAttributeContext() )
|
||||
);
|
||||
|
||||
bindAttributes( attributeSource, componentAttributeBinding );
|
||||
}
|
||||
|
||||
private void bindPersistentCollection(PluralAttributeSource attributeSource, AttributeBindingContainer attributeBindingContainer) {
|
||||
final PluralAttribute existingAttribute = attributeBindingContainer.getAttributeContainer().locatePluralAttribute( attributeSource.getName() );
|
||||
final AbstractPluralAttributeBinding pluralAttributeBinding;
|
||||
|
||||
if ( attributeSource.getPluralAttributeNature() == PluralAttributeNature.BAG ) {
|
||||
final PluralAttribute attribute = existingAttribute != null
|
||||
? existingAttribute
|
||||
: entityBinding.getEntity().createBag( attributeSource.getName() );
|
||||
pluralAttributeBinding = entityBinding.makeBagAttributeBinding(
|
||||
: attributeBindingContainer.getAttributeContainer().createBag( attributeSource.getName() );
|
||||
pluralAttributeBinding = attributeBindingContainer.makeBagAttributeBinding(
|
||||
attribute,
|
||||
convert( attributeSource.getPluralAttributeElementNature() )
|
||||
);
|
||||
|
@ -446,27 +470,26 @@ public class Binder {
|
|||
|
||||
private SimpleSingularAttributeBinding doBasicSingularAttributeBindingCreation(
|
||||
SingularAttributeSource attributeSource,
|
||||
EntityBinding entityBinding) {
|
||||
final SingularAttribute existingAttribute = entityBinding.getEntity()
|
||||
.locateSingularAttribute( attributeSource.getName() );
|
||||
AttributeBindingContainer attributeBindingContainer) {
|
||||
final SingularAttribute existingAttribute = attributeBindingContainer.getAttributeContainer().locateSingularAttribute( attributeSource.getName() );
|
||||
final SingularAttribute attribute;
|
||||
if ( existingAttribute != null ) {
|
||||
attribute = existingAttribute;
|
||||
}
|
||||
else if ( attributeSource.isVirtualAttribute() ) {
|
||||
attribute = entityBinding.getEntity().createVirtualSingularAttribute( attributeSource.getName() );
|
||||
attribute = attributeBindingContainer.getAttributeContainer().createVirtualSingularAttribute( attributeSource.getName() );
|
||||
}
|
||||
else {
|
||||
attribute = entityBinding.getEntity().createSingularAttribute( attributeSource.getName() );
|
||||
attribute = attributeBindingContainer.getAttributeContainer().createSingularAttribute( attributeSource.getName() );
|
||||
}
|
||||
|
||||
final SimpleSingularAttributeBinding attributeBinding;
|
||||
if ( attributeSource.getNature() == SingularAttributeNature.BASIC ) {
|
||||
attributeBinding = entityBinding.makeSimpleAttributeBinding( attribute );
|
||||
attributeBinding = attributeBindingContainer.makeSimpleAttributeBinding( attribute );
|
||||
resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
|
||||
}
|
||||
else if ( attributeSource.getNature() == SingularAttributeNature.MANY_TO_ONE ) {
|
||||
attributeBinding = entityBinding.makeManyToOneAttributeBinding( attribute );
|
||||
attributeBinding = attributeBindingContainer.makeManyToOneAttributeBinding( attribute );
|
||||
resolveTypeInformation( attributeSource.getTypeInformation(), attributeBinding );
|
||||
resolveToOneInformation(
|
||||
(ToOneAttributeSource) attributeSource,
|
||||
|
@ -492,7 +515,7 @@ public class Binder {
|
|||
bindRelationalValues( attributeSource, attributeBinding );
|
||||
|
||||
attributeBinding.setMetaAttributeContext(
|
||||
buildMetaAttributeContext( attributeSource.metaAttributes(), entityBinding.getMetaAttributeContext() )
|
||||
buildMetaAttributeContext( attributeSource.metaAttributes(), attributeBindingContainer.getMetaAttributeContext() )
|
||||
);
|
||||
|
||||
return attributeBinding;
|
||||
|
@ -660,7 +683,7 @@ public class Binder {
|
|||
private void bindTableUniqueConstraints(EntitySource entitySource, EntityBinding entityBinding) {
|
||||
for ( ConstraintSource constraintSource : entitySource.getConstraints() ) {
|
||||
if ( constraintSource instanceof UniqueConstraintSource ) {
|
||||
TableSpecification table = entityBinding.getTable( constraintSource.getTableName() );
|
||||
TableSpecification table = entityBinding.locateTable( constraintSource.getTableName() );
|
||||
if ( table == null ) {
|
||||
// throw exception !?
|
||||
}
|
||||
|
@ -685,8 +708,8 @@ public class Binder {
|
|||
|
||||
if ( relationalValueSourceContainer.relationalValueSources().size() > 0 ) {
|
||||
for ( RelationalValueSource valueSource : relationalValueSourceContainer.relationalValueSources() ) {
|
||||
final TableSpecification table = attributeBinding.getEntityBinding()
|
||||
.getTable( valueSource.getContainingTableName() );
|
||||
final TableSpecification table = attributeBinding.getContainer()
|
||||
.locateTable( valueSource.getContainingTableName() );
|
||||
|
||||
if ( ColumnSource.class.isInstance( valueSource ) ) {
|
||||
final ColumnSource columnSource = ColumnSource.class.cast( valueSource );
|
||||
|
@ -714,7 +737,7 @@ public class Binder {
|
|||
.propertyToColumnName( attributeBinding.getAttribute().getName() );
|
||||
valueBindings.add(
|
||||
new SimpleValueBinding(
|
||||
attributeBinding.getEntityBinding().getBaseTable().locateOrCreateColumn( name )
|
||||
attributeBinding.getContainer().getPrimaryTable().locateOrCreateColumn( name )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -724,7 +747,7 @@ public class Binder {
|
|||
private SimpleValue makeSimpleValue(
|
||||
EntityBinding entityBinding,
|
||||
RelationalValueSource valueSource) {
|
||||
final TableSpecification table = entityBinding.getTable( valueSource.getContainingTableName() );
|
||||
final TableSpecification table = entityBinding.locateTable( valueSource.getContainingTableName() );
|
||||
|
||||
if ( ColumnSource.class.isInstance( valueSource ) ) {
|
||||
return makeColumn( (ColumnSource) valueSource, table );
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* 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.source.binder;
|
||||
|
||||
import org.hibernate.internal.util.Value;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ComponentAttributeSource extends SingularAttributeSource, AttributeSourceContainer {
|
||||
public String getClassName();
|
||||
public Value<Class<?>> getClassReference();
|
||||
|
||||
public String getParentReferenceAttributeName();
|
||||
}
|
|
@ -47,7 +47,7 @@ public interface EntitySource extends SubclassEntityContainer, AttributeSourceCo
|
|||
*
|
||||
* @return The local binding context
|
||||
*/
|
||||
public LocalBindingContext getBindingContext();
|
||||
public LocalBindingContext getLocalBindingContext();
|
||||
|
||||
/**
|
||||
* Obtain the entity name
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.hibernate.metamodel.source.binder.SubclassEntitySource;
|
|||
import org.hibernate.metamodel.source.binder.TableSource;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLAnyElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLComponentElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLManyToManyElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLManyToOneElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLOneToManyElement;
|
||||
|
@ -78,7 +79,7 @@ public abstract class AbstractEntitySourceImpl implements EntitySource {
|
|||
}
|
||||
|
||||
@Override
|
||||
public LocalBindingContext getBindingContext() {
|
||||
public LocalBindingContext getLocalBindingContext() {
|
||||
return sourceMappingDocument.getMappingLocalBindingContext();
|
||||
}
|
||||
|
||||
|
@ -91,7 +92,7 @@ public abstract class AbstractEntitySourceImpl implements EntitySource {
|
|||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return getBindingContext().qualifyClassName( entityElement.getName() );
|
||||
return getLocalBindingContext().qualifyClassName( entityElement.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -154,7 +155,7 @@ public abstract class AbstractEntitySourceImpl implements EntitySource {
|
|||
|
||||
@Override
|
||||
public String getCustomPersisterClassName() {
|
||||
return getBindingContext().qualifyClassName( entityElement.getPersister() );
|
||||
return getLocalBindingContext().qualifyClassName( entityElement.getPersister() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -191,6 +192,11 @@ public abstract class AbstractEntitySourceImpl implements EntitySource {
|
|||
return Helper.buildMetaAttributeSources( entityElement.getMeta() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return sourceMappingDocument.getMappingLocalBindingContext().determineEntityName( entityElement );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeSource> attributeSources() {
|
||||
List<AttributeSource> attributeSources = new ArrayList<AttributeSource>();
|
||||
|
@ -203,6 +209,15 @@ public abstract class AbstractEntitySourceImpl implements EntitySource {
|
|||
)
|
||||
);
|
||||
}
|
||||
else if ( XMLComponentElement.class.isInstance( attributeElement ) ) {
|
||||
attributeSources.add(
|
||||
new ComponentAttributeSourceImpl(
|
||||
(XMLComponentElement) attributeElement,
|
||||
this,
|
||||
sourceMappingDocument.getMappingLocalBindingContext()
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( XMLManyToOneElement.class.isInstance( attributeElement ) ) {
|
||||
attributeSources.add(
|
||||
new ManyToOneAttributeSourceImpl(
|
||||
|
|
|
@ -0,0 +1,220 @@
|
|||
/*
|
||||
* 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.source.hbm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.source.LocalBindingContext;
|
||||
import org.hibernate.metamodel.source.binder.AttributeSource;
|
||||
import org.hibernate.metamodel.source.binder.AttributeSourceContainer;
|
||||
import org.hibernate.metamodel.source.binder.ComponentAttributeSource;
|
||||
import org.hibernate.metamodel.source.binder.ExplicitHibernateTypeSource;
|
||||
import org.hibernate.metamodel.source.binder.MetaAttributeSource;
|
||||
import org.hibernate.metamodel.source.binder.RelationalValueSource;
|
||||
import org.hibernate.metamodel.source.binder.SingularAttributeNature;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLAnyElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLComponentElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLManyToManyElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLManyToOneElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLOneToManyElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLOneToOneElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLPropertyElement;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ComponentAttributeSourceImpl implements ComponentAttributeSource {
|
||||
private final XMLComponentElement componentElement;
|
||||
private final AttributeSourceContainer parentContainer;
|
||||
|
||||
private final Value<Class<?>> componentClassReference;
|
||||
private final String path;
|
||||
|
||||
public ComponentAttributeSourceImpl(
|
||||
XMLComponentElement componentElement,
|
||||
AttributeSourceContainer parentContainer,
|
||||
LocalBindingContext bindingContext) {
|
||||
this.componentElement = componentElement;
|
||||
this.parentContainer = parentContainer;
|
||||
|
||||
this.componentClassReference = bindingContext.makeClassReference( componentElement.getClazz() );
|
||||
this.path = parentContainer.getPath() + '.' + componentElement.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return componentElement.getClazz();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value<Class<?>> getClassReference() {
|
||||
return componentClassReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalBindingContext getLocalBindingContext() {
|
||||
return parentContainer.getLocalBindingContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentReferenceAttributeName() {
|
||||
return componentElement.getParent() == null ? null : componentElement.getParent().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<AttributeSource> attributeSources() {
|
||||
List<AttributeSource> attributeSources = new ArrayList<AttributeSource>();
|
||||
for ( Object attributeElement : componentElement.getPropertyOrManyToOneOrOneToOne() ) {
|
||||
if ( XMLPropertyElement.class.isInstance( attributeElement ) ) {
|
||||
attributeSources.add(
|
||||
new PropertyAttributeSourceImpl(
|
||||
XMLPropertyElement.class.cast( attributeElement ),
|
||||
getLocalBindingContext()
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( XMLComponentElement.class.isInstance( attributeElement ) ) {
|
||||
attributeSources.add(
|
||||
new ComponentAttributeSourceImpl(
|
||||
(XMLComponentElement) attributeElement,
|
||||
this,
|
||||
getLocalBindingContext()
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( XMLManyToOneElement.class.isInstance( attributeElement ) ) {
|
||||
attributeSources.add(
|
||||
new ManyToOneAttributeSourceImpl(
|
||||
XMLManyToOneElement.class.cast( attributeElement ),
|
||||
getLocalBindingContext()
|
||||
)
|
||||
);
|
||||
}
|
||||
else if ( XMLOneToOneElement.class.isInstance( attributeElement ) ) {
|
||||
// todo : implement
|
||||
}
|
||||
else if ( XMLAnyElement.class.isInstance( attributeElement ) ) {
|
||||
// todo : implement
|
||||
}
|
||||
else if ( XMLOneToManyElement.class.isInstance( attributeElement ) ) {
|
||||
// todo : implement
|
||||
}
|
||||
else if ( XMLManyToManyElement.class.isInstance( attributeElement ) ) {
|
||||
// todo : implement
|
||||
}
|
||||
}
|
||||
return attributeSources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVirtualAttribute() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SingularAttributeNature getNature() {
|
||||
return SingularAttributeNature.COMPONENT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExplicitHibernateTypeSource getTypeInformation() {
|
||||
// <component/> does not support type information.
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return componentElement.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingular() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyAccessorName() {
|
||||
return componentElement.getAccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsertable() {
|
||||
return componentElement.isInsert();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdatable() {
|
||||
return componentElement.isUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyGeneration getGeneration() {
|
||||
// todo : is this correct here?
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLazy() {
|
||||
return componentElement.isLazy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIncludedInOptimisticLocking() {
|
||||
return componentElement.isOptimisticLock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MetaAttributeSource> metaAttributes() {
|
||||
return Helper.buildMetaAttributeSources( componentElement.getMeta() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areValuesIncludedInInsertByDefault() {
|
||||
return isInsertable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areValuesIncludedInUpdateByDefault() {
|
||||
return isUpdatable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areValuesNullableByDefault() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RelationalValueSource> relationalValueSources() {
|
||||
// none, they are defined on the simple sub-attributes
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -190,6 +190,11 @@ public class RootEntitySourceImpl extends AbstractEntitySourceImpl implements Ro
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDiscriminatorMatchValue() {
|
||||
return entityElement().getDiscriminatorValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DiscriminatorSource getDiscriminatorSource() {
|
||||
final XMLHibernateMapping.XMLClass.XMLDiscriminator discriminatorElement = entityElement().getDiscriminator();
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.hibernate.metamodel.source.binder.SubclassEntitySource;
|
|||
import org.hibernate.metamodel.source.binder.TableSource;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLJoinedSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLSubclassElement;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLUnionSubclassElement;
|
||||
|
||||
/**
|
||||
|
@ -89,4 +90,11 @@ public class SubclassEntitySourceImpl extends AbstractEntitySourceImpl implement
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDiscriminatorMatchValue() {
|
||||
return XMLSubclassElement.class.isInstance( entityElement() )
|
||||
? ( (XMLSubclassElement) entityElement() ).getDiscriminatorValue()
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class AssociationResolver {
|
|||
}
|
||||
AttributeBinding referencedAttributeBinding =
|
||||
attributeBinding.isPropertyReference() ?
|
||||
entityBinding.getAttributeBinding( attributeBinding.getReferencedAttributeName() ) :
|
||||
entityBinding.locateAttributeBinding( attributeBinding.getReferencedAttributeName() ) :
|
||||
entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding();
|
||||
if ( referencedAttributeBinding == null ) {
|
||||
// TODO: does attribute name include path w/ entity name?
|
||||
|
|
|
@ -52,7 +52,7 @@ class AttributeTypeResolver {
|
|||
|
||||
void resolve() {
|
||||
for ( EntityBinding entityBinding : metadata.getEntityBindings() ) {
|
||||
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindings() ) {
|
||||
for ( AttributeBinding attributeBinding : entityBinding.attributeBindings() ) {
|
||||
resolveTypeInformation( attributeBinding );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -424,7 +424,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
}
|
||||
|
||||
public void addCollection(AbstractPluralAttributeBinding pluralAttributeBinding) {
|
||||
final String owningEntityName = pluralAttributeBinding.getEntityBinding().getEntity().getName();
|
||||
final String owningEntityName = pluralAttributeBinding.getContainer().getPathBase();
|
||||
final String attributeName = pluralAttributeBinding.getAttribute().getName();
|
||||
final String collectionRole = owningEntityName + '.' + attributeName;
|
||||
if ( collectionBindingMap.containsKey( collectionRole ) ) {
|
||||
|
@ -535,7 +535,7 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
|
|||
throw new MappingException( "Entity binding not known: " + entityName );
|
||||
}
|
||||
// TODO: should this call EntityBinding.getReferencedAttributeBindingString), which does not exist yet?
|
||||
AttributeBinding attributeBinding = entityBinding.getAttributeBinding( propertyName );
|
||||
AttributeBinding attributeBinding = entityBinding.locateAttributeBinding( propertyName );
|
||||
if ( attributeBinding == null ) {
|
||||
throw new MappingException( "unknown property: " + entityName + '.' + propertyName );
|
||||
}
|
||||
|
|
|
@ -100,7 +100,6 @@ import org.hibernate.metamodel.binding.EntityBinding;
|
|||
import org.hibernate.metamodel.binding.SimpleValueBinding;
|
||||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.relational.DerivedValue;
|
||||
import org.hibernate.metamodel.relational.SimpleValue;
|
||||
import org.hibernate.metamodel.relational.Value;
|
||||
import org.hibernate.pretty.MessageHelper;
|
||||
import org.hibernate.property.BackrefPropertyAccessor;
|
||||
|
@ -802,7 +801,7 @@ public abstract class AbstractEntityPersister
|
|||
loaderName = entityBinding.getCustomLoaderName();
|
||||
|
||||
int i = 0;
|
||||
for ( org.hibernate.metamodel.relational.Column col : entityBinding.getBaseTable().getPrimaryKey().getColumns() ) {
|
||||
for ( org.hibernate.metamodel.relational.Column col : entityBinding.getPrimaryTable().getPrimaryKey().getColumns() ) {
|
||||
rootTableKeyColumnNames[i] = col.getColumnName().encloseInQuotesIfQuoted( factory.getDialect() );
|
||||
if ( col.getReadFragment() == null ) {
|
||||
rootTableKeyColumnReaders[i] = rootTableKeyColumnNames[i];
|
||||
|
@ -813,7 +812,7 @@ public abstract class AbstractEntityPersister
|
|||
rootTableKeyColumnReaderTemplates[i] = getTemplateFromString( col.getReadFragment(), factory );
|
||||
}
|
||||
// TODO: Fix when HHH-6337 is fixed; for now assume entityBinding is the root
|
||||
// identifierAliases[i] = col.getAlias( factory.getDialect(), entityBinding.getRootEntityBinding().getBaseTable() );
|
||||
// identifierAliases[i] = col.getAlias( factory.getDialect(), entityBinding.getRootEntityBinding().getPrimaryTable() );
|
||||
identifierAliases[i] = col.getAlias( factory.getDialect() );
|
||||
i++;
|
||||
}
|
||||
|
@ -878,7 +877,7 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
thisClassProperties.add( singularAttributeBinding );
|
||||
|
||||
propertySubclassNames[i] = singularAttributeBinding.getEntityBinding().getEntity().getName();
|
||||
propertySubclassNames[i] = ( (EntityBinding) singularAttributeBinding.getContainer() ).getEntity().getName();
|
||||
|
||||
int span = singularAttributeBinding.getSimpleValueSpan();
|
||||
propertyColumnSpans[i] = span;
|
||||
|
@ -983,7 +982,7 @@ public abstract class AbstractEntityPersister
|
|||
final SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
|
||||
|
||||
names.add( singularAttributeBinding.getAttribute().getName() );
|
||||
classes.add( singularAttributeBinding.getEntityBinding().getEntity().getName() );
|
||||
classes.add( ( (EntityBinding) singularAttributeBinding.getContainer() ).getEntity().getName() );
|
||||
boolean isDefinedBySubclass = ! thisClassProperties.contains( singularAttributeBinding );
|
||||
definedBySubclass.add( isDefinedBySubclass );
|
||||
propNullables.add( singularAttributeBinding.isNullable() || isDefinedBySubclass ); //TODO: is this completely correct?
|
||||
|
|
|
@ -467,8 +467,8 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
keyColumnNames = new String[joinSpan][];
|
||||
|
||||
// TODO: fix when EntityBinhding.getRootEntityBinding() exists (HHH-6337)
|
||||
//final Table table = entityBinding.getRootEntityBinding().getBaseTable();
|
||||
final TableSpecification table = entityBinding.getBaseTable();
|
||||
//final Table table = entityBinding.getRootEntityBinding().getPrimaryTable();
|
||||
final TableSpecification table = entityBinding.getPrimaryTable();
|
||||
qualifiedTableNames[0] = table.getQualifiedName( factory.getDialect() );
|
||||
isInverseTable[0] = false;
|
||||
isNullableTable[0] = false;
|
||||
|
@ -571,7 +571,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
discriminatorColumnReaderTemplate = getTemplateFromColumn( column, factory );
|
||||
// TODO: fix this when EntityBinding.getRootEntityBinding() is implemented;
|
||||
// for now, assume entityBinding is the root
|
||||
//discriminatorAlias = column.getAlias( factory.getDialect(), entityBinding.getRootEntityBinding().getBaseTable );
|
||||
//discriminatorAlias = column.getAlias( factory.getDialect(), entityBinding.getRootEntityBinding().getPrimaryTable );
|
||||
discriminatorAlias = column.getAlias( factory.getDialect() );
|
||||
discriminatorFormula = null;
|
||||
discriminatorFormulaTemplate = null;
|
||||
|
@ -663,7 +663,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
//propertyTableNumbersByName.put( singularAttributeBinding.getName(), join );
|
||||
propertyTableNumbersByNameAndSubclass.put(
|
||||
singularAttributeBinding.getEntityBinding().getEntity().getName() + '.' + singularAttributeBinding.getAttribute().getName(),
|
||||
singularAttributeBinding.getContainer().getPathBase() + '.' + singularAttributeBinding.getAttribute().getName(),
|
||||
join
|
||||
);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ public class PropertyFactory {
|
|||
mappedUnsavedValue,
|
||||
getGetter( property ),
|
||||
(VersionType) property.getHibernateTypeDescriptor().getResolvedTypeMapping(),
|
||||
getConstructor( property.getEntityBinding() )
|
||||
getConstructor( (EntityBinding) property.getContainer() )
|
||||
);
|
||||
|
||||
boolean lazy = lazyAvailable && property.isLazy();
|
||||
|
@ -390,13 +390,13 @@ public class PropertyFactory {
|
|||
}
|
||||
|
||||
private static Getter getGetter(AttributeBinding mappingProperty) {
|
||||
if ( mappingProperty == null || mappingProperty.getEntityBinding().getEntity() == null ) {
|
||||
if ( mappingProperty == null || mappingProperty.getContainer().getClassReference() == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PropertyAccessor pa = PropertyAccessorFactory.getPropertyAccessor( mappingProperty, EntityMode.POJO );
|
||||
return pa.getGetter(
|
||||
mappingProperty.getEntityBinding().getEntity().getClassReference(),
|
||||
mappingProperty.getContainer().getClassReference(),
|
||||
mappingProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -294,7 +294,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
// }
|
||||
//}
|
||||
|
||||
for ( AttributeBinding property : entityBinding.getAttributeBindings() ) {
|
||||
for ( AttributeBinding property : entityBinding.attributeBindings() ) {
|
||||
Method method = getGetter( property ).getMethod();
|
||||
if ( method != null && Modifier.isFinal( method.getModifiers() ) ) {
|
||||
LOG.gettersOfLazyClassesCannotBeFinal(entityBinding.getEntity().getName(), property.getAttribute().getName());
|
||||
|
@ -462,14 +462,14 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
|
||||
private Getter getGetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException {
|
||||
return getPropertyAccessor( mappedProperty ).getGetter(
|
||||
mappedProperty.getEntityBinding().getEntity().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
||||
private Setter getSetter(AttributeBinding mappedProperty) throws PropertyNotFoundException, MappingException {
|
||||
return getPropertyAccessor( mappedProperty ).getSetter(
|
||||
mappedProperty.getEntityBinding().getEntity().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getAttribute().getName()
|
||||
);
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer {
|
|||
private PropertyAccessor getPropertyAccessor(AttributeBinding mappedProperty) throws MappingException {
|
||||
// TODO: Fix this then backrefs are working in new metamodel
|
||||
return PropertyAccessorFactory.getPropertyAccessor(
|
||||
mappedProperty.getEntityBinding().getEntity().getClassReference(),
|
||||
mappedProperty.getContainer().getClassReference(),
|
||||
mappedProperty.getPropertyAccessorName()
|
||||
);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import java.util.Iterator;
|
|||
import java.util.Set;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -61,12 +62,10 @@ import static org.junit.Assert.assertTrue;
|
|||
public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
||||
|
||||
private BasicServiceRegistryImpl serviceRegistry;
|
||||
private MetadataSources sources;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
serviceRegistry = (BasicServiceRegistryImpl) new ServiceRegistryBuilder().buildServiceRegistry();
|
||||
sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -80,7 +79,9 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void testSimpleEntityMapping() {
|
||||
MetadataImpl metadata = addSourcesForSimpleEntityBinding( sources );
|
||||
MetadataSources sources = new MetadataSources( serviceRegistry );
|
||||
addSourcesForSimpleEntityBinding( sources );
|
||||
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||
EntityBinding entityBinding = metadata.getEntityBinding( SimpleEntity.class.getName() );
|
||||
assertRoot( metadata, entityBinding );
|
||||
assertIdAndSimpleProperty( entityBinding );
|
||||
|
@ -90,7 +91,9 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void testSimpleVersionedEntityMapping() {
|
||||
MetadataImpl metadata = addSourcesForSimpleVersionedEntityBinding( sources );
|
||||
MetadataSources sources = new MetadataSources( serviceRegistry );
|
||||
addSourcesForSimpleVersionedEntityBinding( sources );
|
||||
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||
EntityBinding entityBinding = metadata.getEntityBinding( SimpleVersionedEntity.class.getName() );
|
||||
assertIdAndSimpleProperty( entityBinding );
|
||||
|
||||
|
@ -100,12 +103,15 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
|
||||
@Test
|
||||
public void testEntityWithManyToOneMapping() {
|
||||
MetadataImpl metadata = addSourcesForManyToOne( sources );
|
||||
MetadataSources sources = new MetadataSources( serviceRegistry );
|
||||
addSourcesForSimpleEntityBinding( sources );
|
||||
addSourcesForManyToOne( sources );
|
||||
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||
|
||||
EntityBinding simpleEntityBinding = metadata.getEntityBinding( SimpleEntity.class.getName() );
|
||||
assertIdAndSimpleProperty( simpleEntityBinding );
|
||||
|
||||
Set<SingularAssociationAttributeBinding> referenceBindings = simpleEntityBinding.getAttributeBinding( "id" )
|
||||
Set<SingularAssociationAttributeBinding> referenceBindings = simpleEntityBinding.locateAttributeBinding( "id" )
|
||||
.getEntityReferencingAttributeBindings();
|
||||
assertEquals( "There should be only one reference binding", 1, referenceBindings.size() );
|
||||
|
||||
|
@ -118,22 +124,41 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
Iterator<SingularAssociationAttributeBinding> it = entityWithManyToOneBinding.getEntityReferencingAttributeBindings()
|
||||
.iterator();
|
||||
assertTrue( it.hasNext() );
|
||||
assertSame( entityWithManyToOneBinding.getAttributeBinding( "simpleEntity" ), it.next() );
|
||||
assertSame( entityWithManyToOneBinding.locateAttributeBinding( "simpleEntity" ), it.next() );
|
||||
assertFalse( it.hasNext() );
|
||||
}
|
||||
|
||||
public abstract MetadataImpl addSourcesForSimpleVersionedEntityBinding(MetadataSources sources);
|
||||
@Test
|
||||
public void testSimpleEntityWithSimpleComponentMapping() {
|
||||
MetadataSources sources = new MetadataSources( serviceRegistry );
|
||||
addSourcesForComponentBinding( sources );
|
||||
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||
EntityBinding entityBinding = metadata.getEntityBinding( SimpleEntityWithSimpleComponent.class.getName() );
|
||||
assertRoot( metadata, entityBinding );
|
||||
assertIdAndSimpleProperty( entityBinding );
|
||||
|
||||
public abstract MetadataImpl addSourcesForSimpleEntityBinding(MetadataSources sources);
|
||||
ComponentAttributeBinding componentAttributeBinding = (ComponentAttributeBinding) entityBinding.locateAttributeBinding( "simpleComponent" );
|
||||
assertNotNull( componentAttributeBinding );
|
||||
assertSame( componentAttributeBinding.getAttribute().getSingularAttributeType(), componentAttributeBinding.getAttributeContainer() );
|
||||
assertEquals( SimpleEntityWithSimpleComponent.class.getName() + ".simpleComponent", componentAttributeBinding.getPathBase() );
|
||||
assertSame( entityBinding.getPrimaryTable(), componentAttributeBinding.getPrimaryTable() );
|
||||
assertNotNull( componentAttributeBinding.getComponent() );
|
||||
}
|
||||
|
||||
public abstract MetadataImpl addSourcesForManyToOne(MetadataSources sources);
|
||||
public abstract void addSourcesForSimpleVersionedEntityBinding(MetadataSources sources);
|
||||
|
||||
public abstract void addSourcesForSimpleEntityBinding(MetadataSources sources);
|
||||
|
||||
public abstract void addSourcesForManyToOne(MetadataSources sources);
|
||||
|
||||
public abstract void addSourcesForComponentBinding(MetadataSources sources);
|
||||
|
||||
protected void assertIdAndSimpleProperty(EntityBinding entityBinding) {
|
||||
assertNotNull( entityBinding );
|
||||
assertNotNull( entityBinding.getHierarchyDetails().getEntityIdentifier() );
|
||||
assertNotNull( entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||
|
||||
AttributeBinding idAttributeBinding = entityBinding.getAttributeBinding( "id" );
|
||||
AttributeBinding idAttributeBinding = entityBinding.locateAttributeBinding( "id" );
|
||||
assertNotNull( idAttributeBinding );
|
||||
assertSame( idAttributeBinding, entityBinding.getHierarchyDetails().getEntityIdentifier().getValueBinding() );
|
||||
assertSame( LongType.INSTANCE, idAttributeBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() );
|
||||
|
@ -152,11 +177,11 @@ public abstract class AbstractBasicBindingTests extends BaseUnitTestCase {
|
|||
assertSame( Types.BIGINT, idDataType.getTypeCode() );
|
||||
assertSame( LongType.INSTANCE.getName(), idDataType.getTypeName() );
|
||||
|
||||
assertNotNull( entityBinding.getAttributeBinding( "name" ) );
|
||||
assertNotNull( entityBinding.getAttributeBinding( "name" ).getAttribute() );
|
||||
assertTrue( entityBinding.getAttributeBinding( "name" ).getAttribute().isSingular() );
|
||||
assertNotNull( entityBinding.locateAttributeBinding( "name" ) );
|
||||
assertNotNull( entityBinding.locateAttributeBinding( "name" ).getAttribute() );
|
||||
assertTrue( entityBinding.locateAttributeBinding( "name" ).getAttribute().isSingular() );
|
||||
|
||||
SingularAttributeBinding nameBinding = (SingularAttributeBinding) entityBinding.getAttributeBinding( "name" );
|
||||
SingularAttributeBinding nameBinding = (SingularAttributeBinding) entityBinding.locateAttributeBinding( "name" );
|
||||
assertSame( StringType.INSTANCE, nameBinding.getHibernateTypeDescriptor().getResolvedTypeMapping() );
|
||||
assertNotNull( nameBinding.getAttribute() );
|
||||
assertNotNull( nameBinding.getValue() );
|
||||
|
|
|
@ -32,19 +32,23 @@ import org.hibernate.metamodel.source.internal.MetadataImpl;
|
|||
* @author Hardy Ferentschik
|
||||
*/
|
||||
public class BasicAnnotationBindingTests extends AbstractBasicBindingTests {
|
||||
public MetadataImpl addSourcesForSimpleEntityBinding(MetadataSources sources) {
|
||||
@Override
|
||||
public void addSourcesForSimpleEntityBinding(MetadataSources sources) {
|
||||
sources.addAnnotatedClass( SimpleEntity.class );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
public MetadataImpl addSourcesForSimpleVersionedEntityBinding(MetadataSources sources) {
|
||||
@Override
|
||||
public void addSourcesForSimpleVersionedEntityBinding(MetadataSources sources) {
|
||||
sources.addAnnotatedClass( SimpleVersionedEntity.class );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
public MetadataImpl addSourcesForManyToOne(MetadataSources sources) {
|
||||
@Override
|
||||
public void addSourcesForManyToOne(MetadataSources sources) {
|
||||
sources.addAnnotatedClass( ManyToOneEntity.class );
|
||||
sources.addAnnotatedClass( SimpleEntity.class );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addSourcesForComponentBinding(MetadataSources sources) {
|
||||
sources.addAnnotatedClass( SimpleEntityWithSimpleComponent.class );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
package org.hibernate.metamodel.binding;
|
||||
|
||||
import org.hibernate.metamodel.MetadataSources;
|
||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||
|
||||
/**
|
||||
* Basic tests of {@code hbm.xml} binding code
|
||||
|
@ -32,19 +31,19 @@ import org.hibernate.metamodel.source.internal.MetadataImpl;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicHbmBindingTests extends AbstractBasicBindingTests {
|
||||
public MetadataImpl addSourcesForSimpleEntityBinding(MetadataSources sources) {
|
||||
public void addSourcesForSimpleEntityBinding(MetadataSources sources) {
|
||||
sources.addResource( "org/hibernate/metamodel/binding/SimpleEntity.hbm.xml" );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
public MetadataImpl addSourcesForSimpleVersionedEntityBinding(MetadataSources sources) {
|
||||
public void addSourcesForSimpleVersionedEntityBinding(MetadataSources sources) {
|
||||
sources.addResource( "org/hibernate/metamodel/binding/SimpleVersionedEntity.hbm.xml" );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
public MetadataImpl addSourcesForManyToOne(MetadataSources sources) {
|
||||
public void addSourcesForManyToOne(MetadataSources sources) {
|
||||
sources.addResource( "org/hibernate/metamodel/binding/ManyToOneEntity.hbm.xml" );
|
||||
sources.addResource( "org/hibernate/metamodel/binding/SimpleEntity.hbm.xml" );
|
||||
return (MetadataImpl) sources.buildMetadata();
|
||||
}
|
||||
|
||||
public void addSourcesForComponentBinding(MetadataSources sources) {
|
||||
sources.addResource( "org/hibernate/metamodel/binding/SimpleEntityWithSimpleComponent.hbm.xml" );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0"?>
|
||||
<hibernate-mapping
|
||||
xmlns="http://www.hibernate.org/xsd/hibernate-mapping"
|
||||
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping hibernate-mapping-4.0.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
package="org.hibernate.metamodel.binding">
|
||||
|
||||
<class name="SimpleEntityWithSimpleComponent">
|
||||
<id name="id">
|
||||
<generator class="increment"/>
|
||||
</id>
|
||||
<property name="name"/>
|
||||
<component name="simpleComponent" class="SimpleEntityWithSimpleComponent$SimpleComponent">
|
||||
<property name="value1"/>
|
||||
<property name="value2"/>
|
||||
</component>
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* 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.binding;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Entity
|
||||
public class SimpleEntityWithSimpleComponent {
|
||||
@Id
|
||||
private Long id;
|
||||
private String name;
|
||||
private SimpleComponent simpleComponent;
|
||||
|
||||
public SimpleEntityWithSimpleComponent() {
|
||||
}
|
||||
|
||||
public SimpleEntityWithSimpleComponent(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SimpleComponent getSimpleComponent() {
|
||||
return simpleComponent;
|
||||
}
|
||||
|
||||
public void setSimpleComponent(SimpleComponent simpleComponent) {
|
||||
this.simpleComponent = simpleComponent;
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
public static class SimpleComponent {
|
||||
private String value1;
|
||||
private String value2;
|
||||
|
||||
public String getValue1() {
|
||||
return value1;
|
||||
}
|
||||
|
||||
public void setValue1(String value1) {
|
||||
this.value1 = value1;
|
||||
}
|
||||
|
||||
public String getValue2() {
|
||||
return value2;
|
||||
}
|
||||
|
||||
public void setValue2(String value2) {
|
||||
this.value2 = value2;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -52,7 +52,7 @@ public class AccessBindingTest extends BaseAnnotationBindingTestCase {
|
|||
@Resources(annotatedClasses = { FieldAccess.class })
|
||||
public void testDefaultFieldAccess() {
|
||||
EntityBinding binding = getEntityBinding( FieldAccess.class );
|
||||
assertEquals( "Wrong access type", "field", binding.getAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
assertEquals( "Wrong access type", "field", binding.locateAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
}
|
||||
|
||||
@Entity
|
||||
|
@ -69,7 +69,7 @@ public class AccessBindingTest extends BaseAnnotationBindingTestCase {
|
|||
@Resources(annotatedClasses = { PropertyAccess.class })
|
||||
public void testDefaultPropertyAccess() {
|
||||
EntityBinding binding = getEntityBinding( PropertyAccess.class );
|
||||
assertEquals( "Wrong access type", "property", binding.getAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
assertEquals( "Wrong access type", "property", binding.locateAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,11 +105,11 @@ public class AccessBindingTest extends BaseAnnotationBindingTestCase {
|
|||
@Resources(annotatedClasses = { MixedAccess.class })
|
||||
public void testMixedAccess() {
|
||||
EntityBinding binding = getEntityBinding( MixedAccess.class );
|
||||
assertEquals( "Wrong access type", "field", binding.getAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
assertEquals( "Wrong access type", "field", binding.locateAttributeBinding( "id" ).getPropertyAccessorName() );
|
||||
assertEquals(
|
||||
"Wrong access type",
|
||||
"property",
|
||||
binding.getAttributeBinding( "name" ).getPropertyAccessorName()
|
||||
binding.locateAttributeBinding( "name" ).getPropertyAccessorName()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ public class AccessBindingTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"Wrong access type",
|
||||
"field",
|
||||
binding.getAttributeBinding( "id" ).getPropertyAccessorName()
|
||||
binding.locateAttributeBinding( "id" ).getPropertyAccessorName()
|
||||
);
|
||||
|
||||
|
||||
|
@ -144,7 +144,7 @@ public class AccessBindingTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"Wrong access type",
|
||||
"property",
|
||||
binding.getAttributeBinding( "name" ).getPropertyAccessorName()
|
||||
binding.locateAttributeBinding( "name" ).getPropertyAccessorName()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ import javax.persistence.MappedSuperclass;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binding.AttributeBinding;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.binding.SingularAttributeBinding;
|
||||
import org.hibernate.metamodel.domain.NonEntity;
|
||||
|
@ -54,7 +53,7 @@ public class MappedSuperclassTest extends BaseAnnotationBindingTestCase {
|
|||
// @Resources(annotatedClasses = { MyMappedSuperClass.class, MyEntity.class, MyMappedSuperClassBase.class })
|
||||
public void testSimpleAttributeOverrideInMappedSuperclass() {
|
||||
EntityBinding binding = getEntityBinding( MyEntity.class );
|
||||
SingularAttributeBinding nameBinding = (SingularAttributeBinding) binding.getAttributeBinding( "name" );
|
||||
SingularAttributeBinding nameBinding = (SingularAttributeBinding) binding.locateAttributeBinding( "name" );
|
||||
assertNotNull( "the name attribute should be bound to MyEntity", nameBinding );
|
||||
|
||||
Column column = (Column) nameBinding.getValue();
|
||||
|
@ -65,7 +64,7 @@ public class MappedSuperclassTest extends BaseAnnotationBindingTestCase {
|
|||
// @Resources(annotatedClasses = { MyMappedSuperClass.class, MyEntity.class, MyMappedSuperClassBase.class })
|
||||
public void testLastAttributeOverrideWins() {
|
||||
EntityBinding binding = getEntityBinding( MyEntity.class );
|
||||
SingularAttributeBinding fooBinding = (SingularAttributeBinding) binding.getAttributeBinding( "foo" );
|
||||
SingularAttributeBinding fooBinding = (SingularAttributeBinding) binding.locateAttributeBinding( "foo" );
|
||||
assertNotNull( "the foo attribute should be bound to MyEntity", fooBinding );
|
||||
|
||||
Column column = (Column) fooBinding.getValue();
|
||||
|
|
|
@ -34,7 +34,7 @@ public class QuotedIdentifierTest extends BaseAnnotationBindingTestCase {
|
|||
}
|
||||
|
||||
private void assertIdentifierEquals(String expected, EntityBinding realValue) {
|
||||
org.hibernate.metamodel.relational.Table table = (org.hibernate.metamodel.relational.Table) realValue.getBaseTable();
|
||||
org.hibernate.metamodel.relational.Table table = (org.hibernate.metamodel.relational.Table) realValue.getPrimaryTable();
|
||||
assertEquals( Identifier.toIdentifier( expected ), table.getTableName() );
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"TableNameTest$A",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
|
||||
binding = getEntityBinding( B.class );
|
||||
|
@ -68,7 +68,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"TableNameTest$A",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"FOO",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
|
||||
binding = getEntityBinding( JoinedB.class );
|
||||
|
@ -101,7 +101,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"TableNameTest$JoinedB",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"TableNameTest$TablePerClassA",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
|
||||
binding = getEntityBinding( TablePerClassB.class );
|
||||
|
@ -134,7 +134,7 @@ public class TableNameTest extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"wrong table name",
|
||||
"TableNameTest$TablePerClassB",
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getBaseTable() ).getTableName().getName()
|
||||
( (org.hibernate.metamodel.relational.Table) binding.getPrimaryTable() ).getTableName().getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class UniqueConstraintBindingTest extends BaseAnnotationBindingTestCase {
|
|||
@Resources(annotatedClasses = TableWithUniqueConstraint.class)
|
||||
public void testTableUniqueConstraints() {
|
||||
EntityBinding binding = getEntityBinding( TableWithUniqueConstraint.class );
|
||||
TableSpecification table = binding.getBaseTable();
|
||||
TableSpecification table = binding.getPrimaryTable();
|
||||
Iterable<UniqueKey> uniqueKeyIterable = table.getUniqueKeys();
|
||||
assertNotNull( uniqueKeyIterable );
|
||||
int i = 0;
|
||||
|
|
Loading…
Reference in New Issue