mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-09 20:54:46 +00:00
HHH-6202 Adding InheritanceType enum
This commit is contained in:
parent
f70f8d7101
commit
ab1dca7e86
@ -23,15 +23,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.metamodel.binding;
|
package org.hibernate.metamodel.binding;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.cfg.NamingStrategy;
|
|
||||||
import org.hibernate.metamodel.domain.Attribute;
|
import org.hibernate.metamodel.domain.Attribute;
|
||||||
import org.hibernate.metamodel.domain.MetaAttribute;
|
import org.hibernate.metamodel.domain.MetaAttribute;
|
||||||
import org.hibernate.metamodel.relational.SimpleValue;
|
import org.hibernate.metamodel.relational.SimpleValue;
|
||||||
import org.hibernate.metamodel.relational.Size;
|
|
||||||
import org.hibernate.metamodel.relational.TableSpecification;
|
import org.hibernate.metamodel.relational.TableSpecification;
|
||||||
import org.hibernate.metamodel.relational.Value;
|
import org.hibernate.metamodel.relational.Value;
|
||||||
|
|
||||||
@ -86,8 +83,9 @@ public interface AttributeBinding {
|
|||||||
public Iterable<SimpleValue> getValues();
|
public Iterable<SimpleValue> getValues();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #getValue()}.{@link Value#getTable() getTable()} instead; to be removed on completion of new metamodel code
|
|
||||||
* @return
|
* @return
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link #getValue()}.{@link Value#getTable() getTable()} instead; to be removed on completion of new metamodel code
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public TableSpecification getTable();
|
public TableSpecification getTable();
|
||||||
@ -95,19 +93,24 @@ public interface AttributeBinding {
|
|||||||
public String getPropertyAccessorName();
|
public String getPropertyAccessorName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean hasFormula();
|
public boolean hasFormula();
|
||||||
|
|
||||||
public boolean isAlternateUniqueKey();
|
public boolean isAlternateUniqueKey();
|
||||||
|
|
||||||
public boolean isNullable();
|
public boolean isNullable();
|
||||||
|
|
||||||
public boolean[] getColumnUpdateability();
|
public boolean[] getColumnUpdateability();
|
||||||
|
|
||||||
public boolean[] getColumnInsertability();
|
public boolean[] getColumnInsertability();
|
||||||
|
|
||||||
public boolean isSimpleValue();
|
public boolean isSimpleValue();
|
||||||
|
|
||||||
public boolean isLazy();
|
public boolean isLazy();
|
||||||
|
|
||||||
public void addEntityReferencingAttributeBinding(EntityReferencingAttributeBinding attributeBinding);
|
public void addEntityReferencingAttributeBinding(EntityReferencingAttributeBinding attributeBinding);
|
||||||
|
|
||||||
public Set<EntityReferencingAttributeBinding> getEntityReferencingAttributeBindings();
|
public Set<EntityReferencingAttributeBinding> getEntityReferencingAttributeBindings();
|
||||||
|
|
||||||
public void validate();
|
public void validate();
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
*/
|
*/
|
||||||
public class EntityBinding {
|
public class EntityBinding {
|
||||||
private final EntityIdentifier entityIdentifier = new EntityIdentifier( this );
|
private final EntityIdentifier entityIdentifier = new EntityIdentifier( this );
|
||||||
|
private InheritanceType entityInheritanceType;
|
||||||
private EntityDiscriminator entityDiscriminator;
|
private EntityDiscriminator entityDiscriminator;
|
||||||
private SimpleAttributeBinding versionBinding;
|
private SimpleAttributeBinding versionBinding;
|
||||||
|
|
||||||
@ -214,6 +215,13 @@ public void bindEntityDiscriminator(SimpleAttributeBinding attributeBinding) {
|
|||||||
baseTable.getPrimaryKey().addColumn( Column.class.cast( attributeBinding.getValue() ) );
|
baseTable.getPrimaryKey().addColumn( Column.class.cast( attributeBinding.getValue() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setInheritanceType(InheritanceType entityInheritanceType) {
|
||||||
|
this.entityInheritanceType = entityInheritanceType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InheritanceType getInheritanceType() {
|
||||||
|
return entityInheritanceType;
|
||||||
|
}
|
||||||
|
|
||||||
public SimpleAttributeBinding getVersioningValueBinding() {
|
public SimpleAttributeBinding getVersioningValueBinding() {
|
||||||
return versionBinding;
|
return versionBinding;
|
||||||
|
@ -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.
|
||||||
|
* <p>
|
||||||
|
* 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() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,6 +39,7 @@
|
|||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.metamodel.binding.Caching;
|
import org.hibernate.metamodel.binding.Caching;
|
||||||
import org.hibernate.metamodel.binding.EntityBinding;
|
import org.hibernate.metamodel.binding.EntityBinding;
|
||||||
|
import org.hibernate.metamodel.binding.InheritanceType;
|
||||||
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
|
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
|
||||||
import org.hibernate.metamodel.domain.Entity;
|
import org.hibernate.metamodel.domain.Entity;
|
||||||
import org.hibernate.metamodel.domain.Hierarchical;
|
import org.hibernate.metamodel.domain.Hierarchical;
|
||||||
@ -69,11 +70,16 @@ public EntityBinder(MetadataImpl metadata, ConfiguredClass configuredClass) {
|
|||||||
|
|
||||||
public void bind() {
|
public void bind() {
|
||||||
EntityBinding entityBinding = new EntityBinding();
|
EntityBinding entityBinding = new EntityBinding();
|
||||||
|
entityBinding.setInheritanceType( InheritanceType.get( configuredClass.getInheritanceType() ) );
|
||||||
|
|
||||||
bindJpaEntityAnnotation( entityBinding );
|
bindJpaEntityAnnotation( entityBinding );
|
||||||
bindHibernateEntityAnnotation( entityBinding ); // optional hibernate specific @org.hibernate.annotations.Entity
|
bindHibernateEntityAnnotation( entityBinding ); // optional hibernate specific @org.hibernate.annotations.Entity
|
||||||
|
|
||||||
bindWhereFilter( entityBinding );
|
bindWhereFilter( entityBinding );
|
||||||
|
|
||||||
bindJpaCaching( entityBinding );
|
bindJpaCaching( entityBinding );
|
||||||
bindHibernateCaching( entityBinding );
|
bindHibernateCaching( entityBinding );
|
||||||
|
|
||||||
schemaName = createSchemaName();
|
schemaName = createSchemaName();
|
||||||
bindTable( entityBinding );
|
bindTable( entityBinding );
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user