diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java index 813c0e01cc..c68b18b298 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/AttributeBinding.java @@ -23,15 +23,12 @@ */ package org.hibernate.metamodel.binding; -import java.util.List; import java.util.Map; import java.util.Set; -import org.hibernate.cfg.NamingStrategy; import org.hibernate.metamodel.domain.Attribute; import org.hibernate.metamodel.domain.MetaAttribute; import org.hibernate.metamodel.relational.SimpleValue; -import org.hibernate.metamodel.relational.Size; import org.hibernate.metamodel.relational.TableSpecification; import org.hibernate.metamodel.relational.Value; @@ -86,8 +83,9 @@ public interface AttributeBinding { public Iterable getValues(); /** - * @deprecated Use {@link #getValue()}.{@link Value#getTable() getTable()} instead; to be removed on completion of new metamodel code * @return + * + * @deprecated Use {@link #getValue()}.{@link Value#getTable() getTable()} instead; to be removed on completion of new metamodel code */ @Deprecated public TableSpecification getTable(); @@ -95,19 +93,24 @@ public interface AttributeBinding { public String getPropertyAccessorName(); /** - * * @return */ public boolean hasFormula(); public boolean isAlternateUniqueKey(); + public boolean isNullable(); + public boolean[] getColumnUpdateability(); + public boolean[] getColumnInsertability(); + public boolean isSimpleValue(); + public boolean isLazy(); public void addEntityReferencingAttributeBinding(EntityReferencingAttributeBinding attributeBinding); + public Set getEntityReferencingAttributeBindings(); public void validate(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java index d9f5f3577a..3d4e486e63 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java @@ -52,6 +52,7 @@ import org.hibernate.metamodel.source.util.MappingHelper; */ public class EntityBinding { private final EntityIdentifier entityIdentifier = new EntityIdentifier( this ); + private InheritanceType entityInheritanceType; private EntityDiscriminator entityDiscriminator; private SimpleAttributeBinding versionBinding; @@ -214,6 +215,13 @@ public class EntityBinding { baseTable.getPrimaryKey().addColumn( Column.class.cast( attributeBinding.getValue() ) ); } + public void setInheritanceType(InheritanceType entityInheritanceType) { + this.entityInheritanceType = entityInheritanceType; + } + + public InheritanceType getInheritanceType() { + return entityInheritanceType; + } public SimpleAttributeBinding getVersioningValueBinding() { return versionBinding; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/InheritanceType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/InheritanceType.java new file mode 100644 index 0000000000..97e317e09f --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/InheritanceType.java @@ -0,0 +1,62 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC 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 Middleware LLC. + * + * 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.MappingException; + +/** + * The inheritance type for a given entity. + *

+ * Note, we are not using the JPA enum, because we need the ability to extend the types if we need to. + * + * @author Hardy Ferentschik + */ +public enum InheritanceType { + JOINED, + SINGLE_TABLE, + TABLE_PER_CLASS; + + /** + * @param jpaType The JPA inheritance type + * + * @return The inheritance type of this class. + */ + public static InheritanceType get(javax.persistence.InheritanceType jpaType) { + switch ( jpaType ) { + case SINGLE_TABLE: { + return InheritanceType.SINGLE_TABLE; + } + case JOINED: { + return InheritanceType.JOINED; + } + case TABLE_PER_CLASS: { + return InheritanceType.TABLE_PER_CLASS; + } + default: { + throw new MappingException( "Unknown jpa inheritance type:" + jpaType.name() ); + } + } + } +} + diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/EntityBinder.java index 3be6aa21cc..3449012652 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/EntityBinder.java @@ -39,6 +39,7 @@ import org.hibernate.cache.spi.access.AccessType; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.binding.Caching; import org.hibernate.metamodel.binding.EntityBinding; +import org.hibernate.metamodel.binding.InheritanceType; import org.hibernate.metamodel.binding.SimpleAttributeBinding; import org.hibernate.metamodel.domain.Entity; import org.hibernate.metamodel.domain.Hierarchical; @@ -69,11 +70,16 @@ public class EntityBinder { public void bind() { EntityBinding entityBinding = new EntityBinding(); + entityBinding.setInheritanceType( InheritanceType.get( configuredClass.getInheritanceType() ) ); + bindJpaEntityAnnotation( entityBinding ); bindHibernateEntityAnnotation( entityBinding ); // optional hibernate specific @org.hibernate.annotations.Entity + bindWhereFilter( entityBinding ); + bindJpaCaching( entityBinding ); bindHibernateCaching( entityBinding ); + schemaName = createSchemaName(); bindTable( entityBinding );