HHH-6171 Restructering packages, especially a new package for the entity binders. This is consistent w/ the glboal package which contains the binders for entity unrelated binding

This commit is contained in:
Hardy Ferentschik 2011-05-17 15:12:57 +02:00
parent f01505591d
commit c7293c2170
23 changed files with 100 additions and 45 deletions

View File

@ -30,6 +30,9 @@ import org.jboss.jandex.Index;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.entity.EntityBinder;
import org.hibernate.metamodel.source.annotations.global.FetchProfileBinder;
import org.hibernate.metamodel.source.annotations.global.TableBinder;
import org.hibernate.metamodel.source.annotations.util.ConfiguredClassHierarchyBuilder;

View File

@ -21,12 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.source.annotations.JPADotNames;
/**
* Container for the properties defined by {@code @Column}.

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
@ -52,6 +52,7 @@ import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.metamodel.binding.InheritanceType;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.source.annotations.util.ReflectionHelper;
import org.hibernate.service.ServiceRegistry;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import java.util.ArrayList;
import java.util.Iterator;
@ -36,6 +36,7 @@ import org.jboss.jandex.MethodInfo;
import org.hibernate.AnnotationException;
import org.hibernate.metamodel.binding.InheritanceType;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.source.annotations.util.ReflectionHelper;
import org.hibernate.service.ServiceRegistry;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
/**
* @author Hardy Ferentschik

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import java.util.List;
import java.util.Map;
@ -29,6 +29,8 @@ import java.util.Map;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
/**

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
@ -37,14 +37,17 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.binding.Caching;
import org.hibernate.metamodel.binding.EntityBinding;
import org.hibernate.metamodel.binding.SimpleAttributeBinding;
import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState;
import org.hibernate.metamodel.domain.Entity;
import org.hibernate.metamodel.domain.Hierarchical;
import org.hibernate.metamodel.relational.Identifier;
import org.hibernate.metamodel.relational.Schema;
import org.hibernate.metamodel.source.annotations.state.binding.AnnotationsAttributeBindingState;
import org.hibernate.metamodel.source.annotations.state.binding.AnnotationsDiscriminatorBindingState;
import org.hibernate.metamodel.source.annotations.state.relational.AttributeColumnRelationalState;
import org.hibernate.metamodel.source.annotations.state.relational.AttributeTupleRelationalState;
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.entity.state.binding.AnnotationsAttributeBindingState;
import org.hibernate.metamodel.source.annotations.entity.state.binding.AnnotationsDiscriminatorBindingState;
import org.hibernate.metamodel.source.annotations.entity.state.relational.AttributeColumnRelationalState;
import org.hibernate.metamodel.source.annotations.entity.state.relational.AttributeTupleRelationalState;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.source.internal.MetadataImpl;
import org.hibernate.service.classloading.spi.ClassLoaderService;
@ -298,9 +301,10 @@ public class EntityBinder {
MappedAttribute idAttribute = configuredClass.getMappedProperty( idName );
entityBinding.getEntity().getOrCreateSingularAttribute( idName );
entityBinding.makeSimpleIdAttributeBinding( idName )
.initialize( new AnnotationsAttributeBindingState( idAttribute ) )
.initialize( new AttributeColumnRelationalState( idAttribute, meta ) );
SimpleAttributeBinding attributeBinding = entityBinding.makeSimpleIdAttributeBinding( idName );
attributeBinding.initialize( new AnnotationsAttributeBindingState( idAttribute ) );
attributeBinding.initialize( new AttributeColumnRelationalState( idAttribute, meta ) );
}
private void bindAttributes(EntityBinding entityBinding) {
@ -317,18 +321,21 @@ public class EntityBinder {
String attributeName = mappedAttribute.getName();
entityBinding.getEntity().getOrCreateSingularAttribute( attributeName );
SimpleAttributeBinding attributeBinding;
SimpleAttributeBindingState bindingState;
if ( mappedAttribute.isDiscriminator() ) {
attributeBinding = entityBinding.makeEntityDiscriminator( attributeName )
.initialize( new AnnotationsDiscriminatorBindingState( mappedAttribute ) )
.getValueBinding();
attributeBinding = entityBinding.makeEntityDiscriminator( attributeName ).getValueBinding();
bindingState = new AnnotationsDiscriminatorBindingState( mappedAttribute );
}
else if ( mappedAttribute.isVersioned() ) {
attributeBinding = entityBinding.makeVersionBinding( attributeName );
bindingState = new AnnotationsAttributeBindingState( mappedAttribute );
}
else {
attributeBinding = mappedAttribute.isVersioned() ?
entityBinding.makeVersionBinding( attributeName ) :
entityBinding.makeSimpleAttributeBinding( attributeName );
attributeBinding.initialize( new AnnotationsAttributeBindingState( mappedAttribute ) );
attributeBinding = entityBinding.makeSimpleAttributeBinding( attributeName );
bindingState = new AnnotationsAttributeBindingState( mappedAttribute );
}
attributeBinding.initialize( bindingState );
if ( configuredClass.hasOwnTable() ) {
AttributeColumnRelationalState columnRelationsState = new AttributeColumnRelationalState(
@ -336,6 +343,7 @@ public class EntityBinder {
);
AttributeTupleRelationalState relationalState = new AttributeTupleRelationalState();
relationalState.addValueState( columnRelationsState );
// TODO: if this really just binds a column, then it can be changed to
// attributeBinding.initialize( columnRelationsState );
attributeBinding.initialize( relationalState );

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
/**
* An emum for the type of id configuration for an entity.

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import java.util.List;
import java.util.Map;
@ -32,9 +32,10 @@ import org.jboss.jandex.DotName;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
/**
* Represent a mapped attribute (explicitly or implicitly mapped). Also used for synthetic attributes likes a
* discriminator column.

View File

@ -0,0 +1,30 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.entity;
/**
* This package contains binding code for entities. In particular it contains classes like {@code ConfiguredClass} and
* {@code MappedAttribute} which are populated from annotations to make it easier to bind to the Hibernate metamodel.
* The configured classes (entities) are also ordered in a ways that they can be bound in the right order.
*/

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.state.binding;
package org.hibernate.metamodel.source.annotations.entity.state.binding;
import java.util.Map;
import java.util.Properties;
@ -29,7 +29,7 @@ import java.util.Properties;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
import org.hibernate.metamodel.source.annotations.entity.MappedAttribute;
/**
* @author Hardy Ferentschik

View File

@ -21,21 +21,22 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.state.binding;
package org.hibernate.metamodel.source.annotations.entity.state.binding;
import org.hibernate.metamodel.source.annotations.DiscriminatorColumnValues;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
import org.hibernate.metamodel.binding.state.DiscriminatorBindingState;
import org.hibernate.metamodel.source.annotations.entity.DiscriminatorColumnValues;
import org.hibernate.metamodel.source.annotations.entity.MappedAttribute;
/**
* @author Gail Badner
*
* TODO: extract a superclass that sets defaults for other stuff
* TODO: extract a superclass that sets defaults for other stuff
*/
public class AnnotationsDiscriminatorBindingState
extends AnnotationsAttributeBindingState implements DiscriminatorBindingState {
private final boolean isForced;
private final boolean isInserted;
public AnnotationsDiscriminatorBindingState(MappedAttribute mappedAttribute) {
super( mappedAttribute );
DiscriminatorColumnValues columnValues = DiscriminatorColumnValues.class.cast( mappedAttribute.getColumnValues() );

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.state.relational;
package org.hibernate.metamodel.source.annotations.entity.state.relational;
import java.util.ArrayList;
import java.util.Arrays;
@ -35,9 +35,9 @@ import org.hibernate.AnnotationException;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.metamodel.relational.Size;
import org.hibernate.metamodel.relational.state.ColumnRelationalState;
import org.hibernate.metamodel.source.annotations.ColumnValues;
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
import org.hibernate.metamodel.source.annotations.entity.ColumnValues;
import org.hibernate.metamodel.source.annotations.entity.MappedAttribute;
import org.hibernate.metamodel.source.internal.MetadataImpl;
/**

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations.state.relational;
package org.hibernate.metamodel.source.annotations.entity.state.relational;
import java.util.ArrayList;
import java.util.List;

View File

@ -24,5 +24,5 @@
package org.hibernate.metamodel.source.annotations;
/**
* This package contains the core binding code for binding annotation based configuration to the Hibernate metadata model.
* This package contains the binding code for binding annotation based configuration to the Hibernate metamodel.
*/

View File

@ -36,8 +36,9 @@ import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.hibernate.AnnotationException;
import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.JPADotNames;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import javax.persistence.Cacheable;
import javax.persistence.Entity;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.source.annotations;
package org.hibernate.metamodel.source.annotations.entity;
import java.util.Iterator;
import java.util.Set;
@ -40,6 +40,8 @@ import org.junit.Before;
import org.junit.Test;
import org.hibernate.metamodel.binding.InheritanceType;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.util.ConfiguredClassHierarchyBuilder;
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
import org.hibernate.service.ServiceRegistryBuilder;

View File

@ -42,8 +42,10 @@ import org.junit.Test;
import org.hibernate.AnnotationException;
import org.hibernate.metamodel.binding.InheritanceType;
import org.hibernate.metamodel.source.annotations.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.BasicServiceRegistryImpl;

View File

@ -38,9 +38,11 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.hibernate.metamodel.source.annotations.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.MappedAttribute;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.metamodel.source.annotations.entity.MappedAttribute;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClass;
import org.hibernate.metamodel.source.annotations.entity.ConfiguredClassHierarchy;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.internal.BasicServiceRegistryImpl;