HHH-7549 @OneToMany support

This commit is contained in:
Strong Liu 2012-08-24 22:56:55 +08:00
parent 449389760f
commit 9bce5e0643
311 changed files with 1244 additions and 1379 deletions

View File

@ -23,8 +23,6 @@
*/
package org.hibernate;
import org.hibernate.tool.hbm2ddl.SchemaExportTask;
/**
* Controls how the session interacts with the second-level
* cache and query cache.

View File

@ -23,8 +23,8 @@
*/
package org.hibernate;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.internal.util.xml.XmlDocument;
import org.hibernate.jaxb.spi.Origin;
/**
* Thrown when a mapping is found to be invalid.

View File

@ -23,11 +23,10 @@
*/
package org.hibernate;
import java.util.List;
import javax.persistence.ParameterMode;
import javax.persistence.TemporalType;
import java.util.List;
import org.hibernate.internal.StoredProcedureCallImpl;
import org.hibernate.type.Type;
/**

View File

@ -29,7 +29,6 @@ import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.CacheKey;
import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.engine.spi.CachedNaturalIdValueSource;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SessionImplementor;
@ -37,7 +36,6 @@ import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.spi.EventType;
import org.hibernate.event.spi.PostDeleteEvent;
import org.hibernate.event.spi.PostDeleteEventListener;
import org.hibernate.event.spi.PostInsertEventListener;
import org.hibernate.event.spi.PreDeleteEvent;
import org.hibernate.event.spi.PreDeleteEventListener;
import org.hibernate.persister.entity.EntityPersister;

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* Describe aliases for filters
*

View File

@ -36,7 +36,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsRegion;
import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.cfg.Settings;
/**
* Factory used if no caching enabled in config...

View File

@ -26,7 +26,6 @@ package org.hibernate.cache.internal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import javax.persistence.EntityNotFoundException;
@ -41,7 +40,6 @@ import org.hibernate.cache.spi.QueryResultsRegion;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.UpdateTimestampsCache;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Settings;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;

View File

@ -23,10 +23,10 @@
*/
package org.hibernate.cfg;
import javax.persistence.AttributeConverter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import javax.persistence.AttributeConverter;
import org.jboss.logging.Logger;

View File

@ -24,7 +24,6 @@
package org.hibernate.cfg;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.cfg;
import javax.persistence.AttributeConverter;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;

View File

@ -38,7 +38,6 @@ import org.hibernate.cache.internal.RegionFactoryInitiator;
import org.hibernate.cache.internal.StandardQueryCacheFactory;
import org.hibernate.cache.spi.QueryCacheFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.transaction.spi.TransactionFactory;
import org.hibernate.hql.spi.QueryTranslatorFactory;
@ -49,6 +48,7 @@ import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jta.platform.spi.JtaPlatform;
import org.hibernate.tuple.entity.EntityTuplizerFactory;

View File

@ -23,15 +23,11 @@
*/
package org.hibernate.cfg.annotations;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.ElementCollection;
@ -45,6 +41,8 @@ import javax.persistence.MapKey;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
@ -112,7 +110,9 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TypeDef;
import org.jboss.logging.Logger;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
/**
* Base class for binding different types of collections to Hibernate configuration objects.

View File

@ -23,14 +23,10 @@
*/
package org.hibernate.cfg.annotations;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import javax.persistence.Access;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
@ -39,6 +35,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable;
import javax.persistence.SecondaryTables;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.EntityMode;
@ -98,7 +96,9 @@ import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.Value;
import org.jboss.logging.Logger;
import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
/**

View File

@ -22,6 +22,7 @@
* Boston, MA 02110-1301 USA
*/
package org.hibernate.cfg.annotations;
import java.util.HashMap;
import javax.persistence.LockModeType;
import javax.persistence.NamedNativeQueries;
@ -42,7 +43,6 @@ import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType;
import org.hibernate.annotations.QueryHints;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException;

View File

@ -24,9 +24,7 @@
package org.hibernate.cfg.annotations;
import java.io.Serializable;
import java.lang.annotation.Annotation;
import java.lang.reflect.TypeVariable;
import java.sql.Types;
import java.util.Calendar;
import java.util.Date;
import java.util.Properties;
@ -41,6 +39,8 @@ import javax.persistence.MapKeyTemporal;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@ -70,8 +70,6 @@ import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.WrappedMaterializedBlobType;
import org.hibernate.usertype.DynamicParameterizedType;
import org.jboss.logging.Logger;
/**
* @author Emmanuel Bernard
*/

View File

@ -23,7 +23,6 @@
*/
package org.hibernate.collection.internal;
import javax.naming.NamingException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
@ -32,6 +31,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import javax.naming.NamingException;
import org.jboss.logging.Logger;

View File

@ -39,7 +39,6 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.hibernate.engine.spi.RowSelection;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
@ -62,6 +61,7 @@ import org.hibernate.dialect.lock.SelectLockingStrategy;
import org.hibernate.dialect.pagination.LegacyLimitHandler;
import org.hibernate.dialect.pagination.LimitHandler;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.exception.spi.ConversionContext;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;

View File

@ -23,6 +23,11 @@
*/
package org.hibernate.dialect;
import java.sql.SQLException;
import java.sql.Types;
import org.jboss.logging.Logger;
import org.hibernate.JDBCException;
import org.hibernate.PessimisticLockException;
import org.hibernate.cfg.AvailableSettings;
@ -38,10 +43,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.type.StandardBasicTypes;
import org.jboss.logging.Logger;
import java.sql.SQLException;
import java.sql.Types;
/**
* A dialect compatible with the H2 database.

View File

@ -27,15 +27,10 @@ import java.sql.SQLException;
import java.util.Map;
import org.hibernate.JDBCException;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.QueryTimeoutException;
import org.hibernate.dialect.function.SQLFunctionTemplate;
import org.hibernate.exception.LockAcquisitionException;
import org.hibernate.exception.LockTimeoutException;
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
import org.hibernate.internal.util.JdbcExceptionHelper;
import org.hibernate.sql.ForUpdateFragment;
import org.hibernate.type.StandardBasicTypes;

View File

@ -3,8 +3,6 @@ package org.hibernate.dialect.pagination;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import org.hibernate.engine.spi.RowSelection;
/**
* Contract defining dialect-specific LIMIT clause handling. Typically implementers might consider extending
* {@link AbstractLimitHandler} class.

View File

@ -41,7 +41,6 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.Status;
import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;

View File

@ -76,7 +76,6 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.sql.Select;
import org.hibernate.tuple.ElementWrapper;
import org.hibernate.type.CollectionType;

View File

@ -39,7 +39,6 @@ import org.hibernate.HibernateException;
import org.hibernate.JDBCException;
import org.hibernate.engine.jdbc.internal.proxy.ProxyBuilder;
import org.hibernate.engine.jdbc.spi.ConnectionObserver;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.engine.jdbc.spi.JdbcResourceRegistry;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.jdbc.spi.LogicalConnectionImplementor;
@ -47,6 +46,7 @@ import org.hibernate.engine.jdbc.spi.NonDurableConnectionObserver;
import org.hibernate.engine.transaction.spi.TransactionContext;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
/**
* Standard Hibernate {@link org.hibernate.engine.jdbc.spi.LogicalConnection} implementation

View File

@ -28,10 +28,10 @@ import java.sql.ResultSet;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.engine.jdbc.LobCreator;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.service.Service;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.service.jdbc.env.spi.JdbcEnvironment;
/**
* Contract for services around JDBC operations. These represent shared resources, aka not varied by session/use.

View File

@ -24,10 +24,10 @@
package org.hibernate.engine.spi;
import org.hibernate.cfg.Configuration;
import org.hibernate.internal.CacheImpl;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.service.spi.SessionFactoryServiceInitiator;
import org.hibernate.internal.CacheImpl;
/**
* @author Strong Liu <stliu@hibernate.org>

View File

@ -23,10 +23,10 @@
*/
package org.hibernate.engine.spi;
import javax.persistence.metamodel.Metamodel;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.persistence.metamodel.Metamodel;
import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.HibernateException;

View File

@ -39,12 +39,12 @@ import org.hibernate.ScrollableResults;
import org.hibernate.cache.spi.CacheKey;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.engine.query.spi.sql.NativeSQLQuerySpecification;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
import org.hibernate.internal.CriteriaImpl;
import org.hibernate.loader.custom.CustomQuery;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.type.Type;
/**

View File

@ -23,8 +23,6 @@
*/
package org.hibernate.engine.spi;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
/**
* @author Steve Ebersole
*/

View File

@ -23,12 +23,12 @@
*/
package org.hibernate.engine.transaction.internal.jta;
import java.sql.Connection;
import java.sql.SQLException;
import javax.transaction.NotSupportedException;
import javax.transaction.SystemException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import java.sql.Connection;
import java.sql.SQLException;
import org.jboss.logging.Logger;

View File

@ -29,7 +29,6 @@ import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
import org.hibernate.engine.spi.CachedNaturalIdValueSource;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.event.spi.ResolveNaturalIdEvent;
import org.hibernate.event.spi.ResolveNaturalIdEventListener;

View File

@ -28,7 +28,6 @@ import java.util.Map;
import antlr.SemanticException;
import antlr.collections.AST;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.hql.internal.antlr.HqlSqlTokenTypes;
import org.hibernate.hql.internal.ast.util.ColumnHelper;
import org.hibernate.internal.util.StringHelper;

View File

@ -37,7 +37,6 @@ import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.mapping.Table;
import org.hibernate.metamodel.spi.relational.Database;
import org.hibernate.metamodel.spi.relational.ObjectName;
import org.hibernate.metamodel.spi.relational.Schema;

View File

@ -26,12 +26,10 @@ package org.hibernate.id;
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Properties;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.MappingException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.id.insert.AbstractReturningDelegate;
@ -39,7 +37,6 @@ import org.hibernate.id.insert.IdentifierGeneratingInsert;
import org.hibernate.id.insert.InsertGeneratedIdentifierDelegate;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.sql.Insert;
import org.hibernate.type.Type;
/**
* A generator which combines sequence generation with immediate retrieval

View File

@ -44,7 +44,6 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.AbstractReturningWork;
import org.hibernate.mapping.Table;
import org.hibernate.metamodel.spi.relational.Database;
import org.hibernate.metamodel.spi.relational.ObjectName;
import org.hibernate.type.Type;

View File

@ -42,8 +42,6 @@ import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.metamodel.spi.relational.Database;
import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.metamodel.spi.relational.ObjectName;
import org.hibernate.metamodel.spi.relational.Schema;
import org.hibernate.metamodel.spi.relational.Sequence;
import org.hibernate.type.Type;
/**

View File

@ -54,7 +54,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.jdbc.AbstractReturningWork;
import org.hibernate.mapping.Table;
import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Database;
import org.hibernate.metamodel.spi.relational.Identifier;

View File

@ -23,9 +23,6 @@
*/
package org.hibernate.internal;
import java.io.Serializable;
import java.util.Map;
import org.hibernate.BasicQueryContract;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;

View File

@ -39,7 +39,6 @@ import org.hibernate.SharedSessionContract;
import org.hibernate.StoredProcedureCall;
import org.hibernate.cache.spi.CacheKey;
import org.hibernate.engine.jdbc.LobCreationContext;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.engine.query.spi.HQLQueryPlan;
import org.hibernate.engine.query.spi.NativeSQLQueryPlan;
import org.hibernate.engine.query.spi.ParameterMetadata;
@ -56,6 +55,7 @@ import org.hibernate.jdbc.WorkExecutor;
import org.hibernate.jdbc.WorkExecutorVisitable;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jdbc.connections.spi.JdbcConnectionAccess;
import org.hibernate.service.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.type.Type;

View File

@ -43,7 +43,6 @@ public class FilterConfiguration {
private final Map<String, String> aliasTableMap;
private final Map<String, String> aliasEntityMap;
private final PersistentClass persistentClass;
public FilterConfiguration(
String name,
String condition,

View File

@ -23,9 +23,6 @@
*/
package org.hibernate.internal;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.persistence.metamodel.Metamodel;
import java.io.IOException;
import java.io.InvalidObjectException;
import java.io.ObjectInputStream;
@ -41,6 +38,9 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.naming.Reference;
import javax.naming.StringRefAddr;
import javax.persistence.metamodel.Metamodel;
import org.jboss.logging.Logger;
@ -112,8 +112,6 @@ import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.integrator.spi.IntegratorService;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
import org.hibernate.jpa.metamodel.internal.JpaMetaModelPopulationSetting;
import org.hibernate.jpa.metamodel.internal.builder.MetamodelBuilder;
import org.hibernate.mapping.Collection;
@ -121,6 +119,7 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.persister.collection.CollectionPersister;
@ -132,6 +131,7 @@ import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.ClassLoadingException;
import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
import org.hibernate.service.config.spi.ConfigurationService;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.jndi.spi.JndiService;

View File

@ -73,10 +73,9 @@ import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionBuilder;
import org.hibernate.SessionException;
import org.hibernate.StoredProcedureCall;
import org.hibernate.engine.spi.SessionOwner;
import org.hibernate.SharedSessionBuilder;
import org.hibernate.SimpleNaturalIdLoadAccess;
import org.hibernate.StoredProcedureCall;
import org.hibernate.Transaction;
import org.hibernate.TransientObjectException;
import org.hibernate.TypeHelper;
@ -99,6 +98,7 @@ import org.hibernate.engine.spi.NonFlushedChanges;
import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SessionOwner;
import org.hibernate.engine.spi.Status;
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
@ -138,7 +138,6 @@ import org.hibernate.event.spi.ResolveNaturalIdEventListener;
import org.hibernate.event.spi.SaveOrUpdateEvent;
import org.hibernate.event.spi.SaveOrUpdateEventListener;
import org.hibernate.internal.CriteriaImpl.CriterionEntry;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work;
import org.hibernate.jdbc.WorkExecutor;

View File

@ -23,8 +23,6 @@
*/
package org.hibernate.internal;
import javax.persistence.ParameterMode;
import javax.persistence.TemporalType;
import java.sql.CallableStatement;
import java.sql.SQLException;
import java.util.ArrayList;
@ -36,6 +34,8 @@ import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.ParameterMode;
import javax.persistence.TemporalType;
import org.jboss.logging.Logger;
@ -47,7 +47,6 @@ import org.hibernate.StoredProcedureCall;
import org.hibernate.StoredProcedureOutputs;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryReturn;
import org.hibernate.engine.query.spi.sql.NativeSQLQueryRootReturn;
import org.hibernate.engine.spi.QueryParameters;
@ -55,6 +54,7 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.jdbc.cursor.spi.RefCursorSupport;
import org.hibernate.service.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.type.DateType;
import org.hibernate.type.ProcedureParameterExtractionAware;
import org.hibernate.type.Type;

View File

@ -23,17 +23,14 @@
*/
package org.hibernate.internal;
import javax.persistence.ParameterMode;
import java.sql.CallableStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.hibernate.JDBCException;
import org.hibernate.StoredProcedureCall.StoredProcedureParameter;
import org.hibernate.StoredProcedureOutputs;
import org.hibernate.StoredProcedureResultSetReturn;
import org.hibernate.StoredProcedureReturn;

View File

@ -52,9 +52,9 @@ import javax.xml.validation.SchemaFactory;
import org.jboss.logging.Logger;
import org.xml.sax.SAXException;
import org.hibernate.internal.util.config.ConfigurationException;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.cfg.JaxbHibernateConfiguration;
import org.hibernate.internal.util.config.ConfigurationException;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.XsdException;
import org.hibernate.service.classloading.spi.ClassLoaderService;

View File

@ -23,6 +23,9 @@
*/
package org.hibernate.jaxb.internal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
@ -31,9 +34,6 @@ import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.EventReaderDelegate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* Used to wrap a StAX {@link XMLEventReader} in order to introduce namespaces into the underlying document. This

View File

@ -23,14 +23,14 @@
*/
package org.hibernate.jpa.metamodel.internal;
import javax.persistence.metamodel.EmbeddableType;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Metamodel;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.EmbeddableType;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.Metamodel;
import org.hibernate.internal.util.collections.CollectionHelper;

View File

@ -23,19 +23,18 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import javax.persistence.OneToOne;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.Type;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.metamodel.internal.AbstractIdentifiableType;
@ -51,10 +50,8 @@ import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;
import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementNature;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexNature;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.domain.PluralAttributeNature;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.ComponentType;
@ -320,53 +317,53 @@ public class AttributeBuilder {
else {
final PluralAttributeBinding pluralAttributeBinding = (PluralAttributeBinding) attributeBinding;
if ( pluralAttributeBinding.getAttribute().getNature() == PluralAttributeNature.ARRAY ) {
if ( pluralAttributeBinding.getAttribute().getNature() == org.hibernate.metamodel.spi.domain.PluralAttribute.Nature.ARRAY ) {
context.handleUnsupportedFeature( UnsupportedFeature.ARRAY );
}
// First, determine the type of the elements and use that to help determine the
// collection type)
final PluralAttributeElementBinding elementBinding = pluralAttributeBinding.getPluralAttributeElementBinding();
final PluralAttributeElementNature elementNature = elementBinding.getPluralAttributeElementNature();
final PluralAttributeElementBinding.Nature elementNature = elementBinding.getNature();
final PersistentAttributeType persistentAttributeType;
final PersistentAttributeType elementPersistentAttributeType;
PersistentAttributeType keyPersistentAttributeType = null;
if ( elementNature == PluralAttributeElementNature.MANY_TO_ANY ) {
if ( elementNature == PluralAttributeElementBinding.Nature.MANY_TO_ANY ) {
// ANY mappings are currently not supported in the JPA metamodel; see HHH-6589
context.handleUnsupportedFeature( UnsupportedFeature.ANY );
return null;
}
else if ( elementNature == PluralAttributeElementNature.BASIC ) {
else if ( elementNature == PluralAttributeElementBinding.Nature.BASIC ) {
elementPersistentAttributeType = PersistentAttributeType.BASIC;
persistentAttributeType = PersistentAttributeType.ELEMENT_COLLECTION;
}
else if ( elementNature == PluralAttributeElementNature.COMPOSITE ) {
else if ( elementNature == PluralAttributeElementBinding.Nature.COMPOSITE ) {
elementPersistentAttributeType = PersistentAttributeType.EMBEDDED;
persistentAttributeType = PersistentAttributeType.ELEMENT_COLLECTION;
}
else {
elementPersistentAttributeType = elementNature == PluralAttributeElementNature.MANY_TO_MANY
elementPersistentAttributeType = elementNature == PluralAttributeElementBinding.Nature.MANY_TO_MANY
? PersistentAttributeType.MANY_TO_MANY
: PersistentAttributeType.ONE_TO_MANY;
persistentAttributeType = elementPersistentAttributeType;
}
// For maps, also check the key binding
if ( pluralAttributeBinding.getAttribute().getNature() == PluralAttributeNature.MAP ) {
if ( pluralAttributeBinding.getAttribute().getNature() == org.hibernate.metamodel.spi.domain.PluralAttribute.Nature.MAP ) {
final IndexedPluralAttributeBinding indexedPluralAttributeBinding
= (IndexedPluralAttributeBinding) pluralAttributeBinding;
final PluralAttributeIndexNature indexNature
final PluralAttributeIndexBinding.Nature indexNature
= indexedPluralAttributeBinding.getPluralAttributeIndexBinding().getPluralAttributeIndexNature();
if ( indexNature == PluralAttributeIndexNature.MANY_TO_ANY ) {
if ( indexNature == PluralAttributeIndexBinding.Nature.MANY_TO_ANY ) {
context.handleUnsupportedFeature( UnsupportedFeature.ANY );
return null;
}
else if ( indexNature == PluralAttributeIndexNature.MANY_TO_MANY ) {
else if ( indexNature == PluralAttributeIndexBinding.Nature.MANY_TO_MANY ) {
keyPersistentAttributeType = Attribute.PersistentAttributeType.MANY_TO_ONE;
}
else if ( indexNature == PluralAttributeIndexNature.COMPOSITE ) {
else if ( indexNature == PluralAttributeIndexBinding.Nature.COMPOSITE ) {
keyPersistentAttributeType = Attribute.PersistentAttributeType.EMBEDDED;
}
else {

View File

@ -23,8 +23,8 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import javax.persistence.metamodel.Attribute;
import java.lang.reflect.Member;
import javax.persistence.metamodel.Attribute;
import org.hibernate.jpa.metamodel.internal.AbstractManagedType;
import org.hibernate.metamodel.spi.binding.AttributeBinding;

View File

@ -23,10 +23,10 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import javax.persistence.metamodel.Attribute;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import javax.persistence.metamodel.Attribute;
import org.hibernate.jpa.metamodel.internal.AbstractManagedType;
import org.hibernate.metamodel.spi.binding.AttributeBinding;

View File

@ -23,21 +23,19 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import org.jboss.logging.Logger;
import org.hibernate.HibernateException;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.jpa.metamodel.internal.AbstractIdentifiableType;
import org.hibernate.jpa.metamodel.internal.EmbeddableTypeImpl;
@ -46,9 +44,6 @@ import org.hibernate.jpa.metamodel.internal.JpaMetaModelPopulationSetting;
import org.hibernate.jpa.metamodel.internal.MappedSuperclassTypeImpl;
import org.hibernate.jpa.metamodel.internal.MetamodelImpl;
import org.hibernate.jpa.metamodel.internal.UnsupportedFeature;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.Property;
import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.BasicAttributeBinding;
import org.hibernate.metamodel.spi.binding.CompositeAttributeBinding;

View File

@ -23,11 +23,11 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.PluralAttribute;
import java.lang.reflect.Member;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.PluralAttribute;
import org.hibernate.annotations.common.AssertionFailure;
import org.hibernate.jpa.metamodel.internal.AbstractManagedType;

View File

@ -23,8 +23,8 @@
*/
package org.hibernate.jpa.metamodel.internal.builder;
import javax.persistence.metamodel.Attribute;
import java.lang.reflect.Member;
import javax.persistence.metamodel.Attribute;
import org.hibernate.jpa.metamodel.internal.AbstractManagedType;
import org.hibernate.metamodel.spi.binding.AttributeBinding;

View File

@ -23,14 +23,14 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.ManagedType;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.ManagedType;
import org.hibernate.internal.util.ReflectHelper;

View File

@ -23,13 +23,13 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
/**
* Defines commonality for the JPA {@link javax.persistence.metamodel.IdentifiableType} types. JPA defines

View File

@ -23,6 +23,11 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.Bindable;
import javax.persistence.metamodel.CollectionAttribute;
@ -32,11 +37,6 @@ import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.SingularAttribute;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.hibernate.annotations.common.AssertionFailure;

View File

@ -23,8 +23,8 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.Type;
import java.io.Serializable;
import javax.persistence.metamodel.Type;
/**
* Defines commonality for the JPA {@link javax.persistence.metamodel.Type} hierarchy of interfaces.

View File

@ -23,18 +23,18 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.Type;
import java.lang.reflect.Field;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.util.Iterator;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.Type;
import org.jboss.logging.Logger;
@ -51,7 +51,6 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.Value;
import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.ComponentType;
import org.hibernate.type.EmbeddedComponentType;
import org.hibernate.type.EntityType;
/**

View File

@ -21,8 +21,8 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.BasicType;
import java.io.Serializable;
import javax.persistence.metamodel.BasicType;
/**
* @author Emmanuel Bernard

View File

@ -21,8 +21,8 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.EmbeddableType;
import java.io.Serializable;
import javax.persistence.metamodel.EmbeddableType;
import org.hibernate.type.ComponentType;

View File

@ -21,8 +21,8 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.EntityType;
import java.io.Serializable;
import javax.persistence.metamodel.EntityType;
/**
* Defines the Hibernate implementation of the JPA {@link javax.persistence.metamodel.EntityType} contract.

View File

@ -23,10 +23,6 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.MappedSuperclassType;
import javax.persistence.metamodel.SingularAttribute;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collections;
@ -36,6 +32,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.Attribute;
import javax.persistence.metamodel.IdentifiableType;
import javax.persistence.metamodel.MappedSuperclassType;
import javax.persistence.metamodel.SingularAttribute;
import org.jboss.logging.Logger;

View File

@ -23,16 +23,16 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.EmbeddableType;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.MappedSuperclassType;
import javax.persistence.metamodel.Metamodel;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.EmbeddableType;
import javax.persistence.metamodel.EntityType;
import javax.persistence.metamodel.ManagedType;
import javax.persistence.metamodel.MappedSuperclassType;
import javax.persistence.metamodel.Metamodel;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;

View File

@ -21,18 +21,18 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.Type;
import java.io.Serializable;
import java.lang.reflect.Member;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.ListAttribute;
import javax.persistence.metamodel.MapAttribute;
import javax.persistence.metamodel.PluralAttribute;
import javax.persistence.metamodel.SetAttribute;
import javax.persistence.metamodel.Type;
import org.hibernate.mapping.Property;

View File

@ -21,10 +21,10 @@
*/
package org.hibernate.jpa.metamodel.internal.legacy;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
import java.io.Serializable;
import java.lang.reflect.Member;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.Type;
/**
* @author Emmanuel Bernard

View File

@ -25,7 +25,6 @@ package org.hibernate.mapping;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import javax.persistence.AttributeConverter;
import java.lang.reflect.TypeVariable;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
@ -35,6 +34,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import javax.persistence.AttributeConverter;
import org.jboss.logging.Logger;

View File

@ -38,10 +38,9 @@ import java.util.Set;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.jboss.logging.Logger;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.jboss.logging.Logger;
import org.w3c.dom.Document;
import org.hibernate.HibernateException;

View File

@ -76,9 +76,8 @@ import org.hibernate.metamodel.spi.binding.MapBinding;
import org.hibernate.metamodel.spi.binding.MetaAttribute;
import org.hibernate.metamodel.spi.binding.OneToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementNature;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeIndexNature;
import org.hibernate.metamodel.spi.binding.PluralAttributeKeyBinding;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SecondaryTable;
@ -127,16 +126,15 @@ import org.hibernate.metamodel.spi.source.MultiTenancySource;
import org.hibernate.metamodel.spi.source.NonAggregatedCompositeIdentifierSource;
import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.Orderable;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.PluralAttributeKeySource;
import org.hibernate.metamodel.spi.source.PluralAttributeNature;
import org.hibernate.metamodel.spi.source.PluralAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.RelationalValueSourceContainer;
import org.hibernate.metamodel.spi.source.RootEntitySource;
import org.hibernate.metamodel.spi.source.SecondaryTableSource;
import org.hibernate.metamodel.spi.source.SimpleIdentifierSource;
import org.hibernate.metamodel.spi.source.SingularAttributeNature;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
import org.hibernate.metamodel.spi.source.Sortable;
import org.hibernate.metamodel.spi.source.SubclassEntitySource;
@ -401,7 +399,7 @@ public class Binder {
private void bindBasicCollectionKey(
final AbstractPluralAttributeBinding attributeBinding,
final PluralAttributeSource attributeSource) {
if ( attributeSource.getElementSource().getNature() != org.hibernate.metamodel.spi.source.PluralAttributeElementNature.BASIC ) {
if ( attributeSource.getElementSource().getNature() != PluralAttributeElementSource.Nature.BASIC ) {
throw new AssertionFailure(
String.format(
"Expected basic attribute binding; instead got {%s}",
@ -437,10 +435,10 @@ public class Binder {
private void bindBasicSetElementTablePrimaryKey(final PluralAttributeBinding attributeBinding) {
final BasicPluralAttributeElementBinding elementBinding =
( BasicPluralAttributeElementBinding ) attributeBinding.getPluralAttributeElementBinding();
if ( elementBinding.getPluralAttributeElementNature() != PluralAttributeElementNature.BASIC ) {
if ( elementBinding.getNature() != PluralAttributeElementBinding.Nature.BASIC ) {
throw new MappingException( String.format(
"Expected a SetBinding with an element of nature PluralAttributeElementNature.BASIC; instead was %s",
elementBinding.getPluralAttributeElementNature() ), bindingContexts.peek().getOrigin() );
"Expected a SetBinding with an element of nature Nature.BASIC; instead was %s",
elementBinding.getNature() ), bindingContexts.peek().getOrigin() );
}
if ( hasAnyNonNullableColumns( elementBinding.getRelationalValueBindings() ) ) {
final PrimaryKey primaryKey = attributeBinding.getPluralAttributeKeyBinding().getCollectionTable().getPrimaryKey();
@ -473,7 +471,7 @@ public class Binder {
attributeSource,
indexedAttributeBinding.getAttribute(),
indexedAttributeBinding.getPluralAttributeKeyBinding().getCollectionTable() ).get( 0 ).getValue() );
if ( attributeBinding.getPluralAttributeElementBinding().getPluralAttributeElementNature() == PluralAttributeElementNature.ONE_TO_MANY ) {
if ( attributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.ONE_TO_MANY ) {
if ( !Column.class.isInstance( indexBinding.getIndexRelationalValue() ) ) {
throw new NotYetImplementedException( "derived value as collection index is not supported yet." );
}
@ -544,15 +542,15 @@ public class Binder {
final AbstractPluralAttributeBinding attributeBinding,
final PluralAttributeSource attributeSource,
final HibernateTypeHelper.ReflectedCollectionJavaTypes reflectedCollectionJavaTypes ) {
PluralAttributeNature pluralAttributeNature = attributeSource.getPluralAttributeNature();
if ( attributeSource.getElementSource().getNature() == org.hibernate.metamodel.spi.source.PluralAttributeElementNature.ONE_TO_MANY
|| pluralAttributeNature == PluralAttributeNature.BAG ) {
PluralAttributeSource.Nature pluralAttributeNature = attributeSource.getNature();
if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.ONE_TO_MANY
|| pluralAttributeNature == PluralAttributeSource.Nature.BAG ) {
return;
}
if ( attributeBinding.getPluralAttributeElementBinding().getPluralAttributeElementNature() == PluralAttributeElementNature.BASIC ) {
if ( pluralAttributeNature == PluralAttributeNature.SET ) {
if ( attributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.BASIC ) {
if ( pluralAttributeNature == PluralAttributeSource.Nature.SET ) {
bindBasicSetElementTablePrimaryKey( attributeBinding );
} else if ( pluralAttributeNature == PluralAttributeNature.LIST || pluralAttributeNature == PluralAttributeNature.MAP ) {
} else if ( pluralAttributeNature == PluralAttributeSource.Nature.LIST || pluralAttributeNature == PluralAttributeSource.Nature.MAP ) {
bindIndexedTablePrimaryKey( ( IndexedPluralAttributeBinding ) attributeBinding );
} else {
throw new NotYetImplementedException( "Only Sets with basic elements are supported so far." );
@ -1207,7 +1205,7 @@ public class Binder {
final AbstractPluralAttributeBinding attributeBinding,
final PluralAttributeSource attributeSource,
final EntityBinding referencedEntityBinding) {
if ( attributeSource.getElementSource().getNature() != org.hibernate.metamodel.spi.source.PluralAttributeElementNature.ONE_TO_MANY ) {
if ( attributeSource.getElementSource().getNature() != PluralAttributeElementSource.Nature.ONE_TO_MANY ) {
throw new AssertionFailure(
String.format(
"Expected one-to-many attribute binding; instead got {%s}",
@ -1219,16 +1217,17 @@ public class Binder {
// TODO: Need to look up the table to be able to create the foreign key
throw new NotYetImplementedException( "one-to-many using a join table is not supported yet." );
}
if(!attributeSource.isInverse()){
TableSpecification collectionTable = referencedEntityBinding.getPrimaryTable();
bindCollectionTableForeignKey( attributeBinding, attributeSource.getKeySource(), collectionTable );
}
attributeBinding.getPluralAttributeKeyBinding().setInverse( attributeSource.isInverse() );
}
private AbstractPluralAttributeBinding bindPluralAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource ) {
final PluralAttributeNature nature = attributeSource.getPluralAttributeNature();
final PluralAttributeSource.Nature nature = attributeSource.getNature();
final PluralAttribute attribute =
attributeBindingContainer.getAttributeContainer().locatePluralAttribute( attributeSource.getName() );
final AbstractPluralAttributeBinding attributeBinding;
@ -1286,14 +1285,14 @@ public class Binder {
bindSortingAndOrdering( attributeBinding, attributeSource );
if ( attributeSource.getElementSource().getNature() == org.hibernate.metamodel.spi.source.PluralAttributeElementNature.BASIC ) {
if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.BASIC ) {
bindBasicCollectionKey( attributeBinding, attributeSource );
bindBasicCollectionElement(
( BasicPluralAttributeElementBinding ) attributeBinding.getPluralAttributeElementBinding(),
( BasicPluralAttributeElementSource ) attributeSource.getElementSource(),
defaultCollectionElementJavaTypeName( reflectedCollectionJavaTypes ) );
}
else if ( attributeSource.getElementSource().getNature() == org.hibernate.metamodel.spi.source.PluralAttributeElementNature.ONE_TO_MANY ) {
else if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.ONE_TO_MANY ) {
final OneToManyPluralAttributeElementSource elementSource =
(OneToManyPluralAttributeElementSource) attributeSource.getElementSource();
final String defaultElementJavaTypeName = defaultCollectionElementJavaTypeName( reflectedCollectionJavaTypes );
@ -1435,7 +1434,7 @@ public class Binder {
final AttributeBindingContainer attributeBindingContainer,
final SingularAttributeSource attributeSource,
boolean isIdentifierAttribute) {
final SingularAttributeNature nature = attributeSource.getNature();
final SingularAttributeSource.Nature nature = attributeSource.getNature();
final SingularAttribute attribute =
attributeBindingContainer.getAttributeContainer().locateSingularAttribute( attributeSource.getName() );
switch ( nature ) {
@ -1466,8 +1465,9 @@ public class Binder {
final Sortable sortable = ( Sortable ) attributeSource;
if ( sortable.isSorted() ) {
Class< Comparator< ? > > comparatorClass =
bindingContext().< Comparator< ? > >locateClassByName( sortable.getComparatorName() );
bindingContext().locateClassByName( sortable.getComparatorName() );
try {
attributeBinding.setSorted( sortable.isSorted() );
attributeBinding.setComparator( comparatorClass.newInstance() );
} catch ( Exception error ) {
bindingContext().makeMappingException(
@ -1874,7 +1874,7 @@ public class Binder {
PluralAttributeSource attributeSource ) {
return reflectedCollectionJavaTypes != null && reflectedCollectionJavaTypes.getCollectionType() != null
? reflectedCollectionJavaTypes.getCollectionType().getName()
: attributeSource.getPluralAttributeNature().reportedJavaType().getName();
: attributeSource.getNature().reportedJavaType().getName();
}
private List< Column > determineForeignKeyTargetColumns(
@ -2118,15 +2118,16 @@ public class Binder {
}
}
private PluralAttributeElementNature pluralAttributeElementNature(PluralAttributeSource attributeSource) {
return PluralAttributeElementNature.valueOf( attributeSource.getElementSource().getNature().name() );
private PluralAttributeElementBinding.Nature pluralAttributeElementNature(PluralAttributeSource attributeSource) {
return PluralAttributeElementBinding.Nature
.valueOf( attributeSource.getElementSource().getNature().name() );
}
private PluralAttributeIndexNature pluralAttributeIndexNature(PluralAttributeSource attributeSource) {
private PluralAttributeIndexBinding.Nature pluralAttributeIndexNature(PluralAttributeSource attributeSource) {
if ( ! IndexedPluralAttributeSource.class.isInstance( attributeSource ) ) {
return null;
}
return PluralAttributeIndexNature.valueOf(
return PluralAttributeIndexBinding.Nature.valueOf(
( (IndexedPluralAttributeSource) attributeSource ).getIndexSource().getNature().name()
);
}
@ -2148,7 +2149,7 @@ public class Binder {
return metadata.getTypeResolver().getTypeFactory().bag(
bagBinding.getAttribute().getRole(),
bagBinding.getReferencedPropertyName(),
bagBinding.getPluralAttributeElementBinding().getPluralAttributeElementNature() == PluralAttributeElementNature.COMPOSITE );
bagBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.COMPOSITE );
}
}
@ -2162,7 +2163,7 @@ public class Binder {
pluralAttributeBinding.getAttribute().getName(),
pluralAttributeBinding.getReferencedPropertyName(),
pluralAttributeBinding.getPluralAttributeElementBinding()
.getPluralAttributeElementNature() == PluralAttributeElementNature.COMPOSITE
.getNature() == PluralAttributeElementBinding.Nature.COMPOSITE
);
}
@ -2174,7 +2175,7 @@ public class Binder {
listBinding.getAttribute().getRole(),
listBinding.getReferencedPropertyName(),
listBinding.getPluralAttributeElementBinding()
.getPluralAttributeElementNature() == PluralAttributeElementNature.COMPOSITE
.getNature() == PluralAttributeElementBinding.Nature.COMPOSITE
);
}
}
@ -2188,7 +2189,7 @@ public class Binder {
mapBinding.getAttribute().getRole(),
mapBinding.getReferencedPropertyName(),
mapBinding.getPluralAttributeElementBinding()
.getPluralAttributeElementNature() == PluralAttributeElementNature.COMPOSITE
.getNature() == PluralAttributeElementBinding.Nature.COMPOSITE
);
}
}
@ -2201,7 +2202,7 @@ public class Binder {
setBinding.getAttribute().getRole(),
setBinding.getReferencedPropertyName(),
setBinding.getPluralAttributeElementBinding()
.getPluralAttributeElementNature() == PluralAttributeElementNature.COMPOSITE
.getNature() == PluralAttributeElementBinding.Nature.COMPOSITE
);
}
}

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Map;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
@ -69,7 +68,7 @@ import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.spi.binding.IdGenerator;
import org.hibernate.metamodel.spi.binding.ManyToOneAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementNature;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeKeyBinding;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.TypeDefinition;
@ -333,8 +332,8 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
// Find one-to-many associations with key bindings that are non-inverse and non-nullable
PluralAttributeKeyBinding keyBinding = pluralAttributeBinding.getPluralAttributeKeyBinding();
if ( keyBinding.isInverse() || keyBinding.isNullable() ||
pluralAttributeBinding.getPluralAttributeElementBinding().getPluralAttributeElementNature() !=
PluralAttributeElementNature.ONE_TO_MANY ) {
pluralAttributeBinding.getPluralAttributeElementBinding().getNature() !=
PluralAttributeElementBinding.Nature.ONE_TO_MANY ) {
continue;
}
// Ensure this isn't a bidirectional association by ensuring FK columns don't match relational columns of any

View File

@ -40,12 +40,12 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.internal.DefaultCustomEntityDirtinessStrategy;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
import org.hibernate.metamodel.SessionFactoryBuilder;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.classloading.spi.ClassLoaderService;
import org.hibernate.service.classloading.spi.StrategyInstanceResolver;
import org.hibernate.service.config.spi.ConfigurationService;
/**

View File

@ -32,7 +32,6 @@ import com.fasterxml.classmate.ResolvedTypeWithMembers;
import com.fasterxml.classmate.TypeResolver;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.hibernate.cfg.NamingStrategy;

View File

@ -32,18 +32,17 @@ import java.util.Map;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableClass;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
import org.hibernate.metamodel.internal.source.annotations.entity.EmbeddableClass;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ComponentAttributeSource;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SingularAttributeNature;
/**
* Annotation backed implementation of {@code ComponentAttributeSource}.
@ -71,8 +70,8 @@ public class ComponentAttributeSourceImpl implements ComponentAttributeSource {
}
@Override
public SingularAttributeNature getNature() {
return SingularAttributeNature.COMPONENT;
public Nature getNature() {
return Nature.COMPONENT;
}
@Override

View File

@ -25,7 +25,6 @@ package org.hibernate.metamodel.internal.source.annotations;
import org.hibernate.metamodel.internal.source.annotations.attribute.FormulaValue;
import org.hibernate.metamodel.spi.source.DerivedValueSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
* @author Strong Liu

View File

@ -36,8 +36,8 @@ import org.jboss.jandex.AnnotationValue;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
@ -47,6 +47,7 @@ import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.source.AttributeSource;
import org.hibernate.metamodel.spi.source.ConstraintSource;
@ -54,7 +55,6 @@ import org.hibernate.metamodel.spi.source.EntitySource;
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.source.PrimaryKeyJoinColumnSource;
import org.hibernate.metamodel.spi.source.SecondaryTableSource;
import org.hibernate.metamodel.spi.source.SubclassEntitySource;
@ -229,18 +229,18 @@ public class EntitySourceImpl implements EntitySource {
}
for ( AssociationAttribute associationAttribute : entityClass.getAssociationAttributes() ) {
switch ( associationAttribute.getAttributeNature() ) {
switch ( associationAttribute.getNature() ) {
case ONE_TO_ONE:
case MANY_TO_ONE: {
attributeList.add( new ToOneAttributeSourceImpl( associationAttribute ) );
break;
}
case MANY_TO_MANY: {
attributeList.add( new PluralAttributeSourceImpl( ( PluralAssociationAttribute ) associationAttribute ) );
break;
}
case MANY_TO_MANY:
case ONE_TO_MANY:
attributeList.add( new PluralAttributeSourceImpl( ( PluralAssociationAttribute ) associationAttribute ) );
AttributeSource source = ((PluralAssociationAttribute)associationAttribute).isIndexed() ?
new IndexedPluralAttributeSourceImpl((PluralAssociationAttribute)associationAttribute )
:new PluralAttributeSourceImpl( ( PluralAssociationAttribute ) associationAttribute );
attributeList.add( source );
break;
default: {
throw new NotYetImplementedException();

View File

@ -23,15 +23,14 @@
*/
package org.hibernate.metamodel.internal.source.annotations;
import javax.persistence.GenerationType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.GenerationType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger;
import org.hibernate.cfg.AvailableSettings;

View File

@ -24,7 +24,6 @@
package org.hibernate.metamodel.internal.source.annotations;
import java.util.Collection;
import java.util.List;
import org.jboss.jandex.AnnotationInstance;

View File

@ -0,0 +1,37 @@
package org.hibernate.metamodel.internal.source.annotations;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public class IndexedPluralAttributeSourceImpl extends PluralAttributeSourceImpl
implements IndexedPluralAttributeSource {
private final PluralAttributeIndexSource indexSource;
public IndexedPluralAttributeSourceImpl(PluralAssociationAttribute attribute) {
super( attribute );
if ( getNature() == org.hibernate.metamodel.spi.source.PluralAttributeSource.Nature.SET || getNature() == org.hibernate.metamodel.spi.source.PluralAttributeSource.Nature.MAP ) {
throw new MappingException(
"Set / Map could not be an indexed column",
attribute.getContext().getOrigin()
);
}
if ( attribute.getNature() != MappedAttribute.Nature.MANY_TO_MANY && attribute.getNature() != MappedAttribute.Nature.ONE_TO_MANY ) {
throw new MappingException(
"Indexed column could be only mapped on the MANY side",
attribute.getContext().getOrigin()
);
}
this.indexSource = new PluralAttributeIndexSourceImpl( this, attribute );
}
@Override
public PluralAttributeIndexSource getIndexSource() {
return indexSource;
}
}

View File

@ -33,7 +33,6 @@ import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.binding.CascadeType;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
@ -86,7 +85,7 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
@Override
public boolean isNotFoundAnException() {
return !associationAttribute.ignoreNotFound();
return !associationAttribute.isIgnoreNotFound();
}
@Override
@ -115,8 +114,8 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
}
@Override
public PluralAttributeElementNature getNature() {
return PluralAttributeElementNature.MANY_TO_MANY;
public Nature getNature() {
return Nature.MANY_TO_MANY;
}
}

View File

@ -29,7 +29,6 @@ import org.hibernate.AssertionFailure;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
/**
* @author Hardy Ferentschik
@ -48,7 +47,7 @@ public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPlura
@Override
public boolean isNotFoundAnException() {
return !associationAttribute.ignoreNotFound();
return !associationAttribute.isIgnoreNotFound();
}
@Override
@ -58,28 +57,29 @@ public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPlura
}
@Override
public PluralAttributeElementNature getNature() {
switch ( associationAttribute.getAttributeNature() ) {
public Nature getNature() {
switch ( associationAttribute.getNature() ) {
case MANY_TO_MANY: {
return PluralAttributeElementNature.MANY_TO_MANY;
return Nature.MANY_TO_MANY;
}
case MANY_TO_ANY: {
return PluralAttributeElementNature.MANY_TO_ANY;
return Nature.MANY_TO_ANY;
}
case ONE_TO_MANY: {
return PluralAttributeElementNature.ONE_TO_MANY;
return Nature.ONE_TO_MANY;
}
case ELEMENT_COLLECTION_BASIC: {
return PluralAttributeElementNature.BASIC;
return Nature.BASIC;
}
case ELEMENT_COLLECTION_EMBEDDABLE: {
return PluralAttributeElementNature.COMPONENT;
return Nature.COMPONENT;
}
default: {
throw new AssertionFailure( "Unexpected attribute nature: " + associationAttribute.getAttributeNature() );
throw new AssertionFailure( "Unexpected attribute nature: " + associationAttribute.getNature() );
}
}
}
}

View File

@ -0,0 +1,61 @@
package org.hibernate.metamodel.internal.source.annotations;
import java.util.List;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeIndexSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public class PluralAttributeIndexSourceImpl implements PluralAttributeIndexSource {
private final PluralAssociationAttribute attribute;
private final IndexedPluralAttributeSourceImpl indexedPluralAttributeSource;
public PluralAttributeIndexSourceImpl(IndexedPluralAttributeSourceImpl indexedPluralAttributeSource, PluralAssociationAttribute attribute) {
this.attribute = attribute;
this.indexedPluralAttributeSource = indexedPluralAttributeSource;
}
@Override
public Nature getNature() {
switch ( indexedPluralAttributeSource.getElementSource().getNature() ){
case BASIC:
return Nature.BASIC;
case COMPONENT:
return Nature.COMPOSITE;
case MANY_TO_ANY:
return Nature.MANY_TO_ANY;
case MANY_TO_MANY:
return Nature.MANY_TO_MANY;
}
return null;
}
@Override
public ExplicitHibernateTypeSource explicitHibernateTypeSource() {
return null;
}
@Override
public List<RelationalValueSource> relationalValueSources() {
return null;
}
@Override
public boolean areValuesIncludedInInsertByDefault() {
return false;
}
@Override
public boolean areValuesIncludedInUpdateByDefault() {
return false;
}
@Override
public boolean areValuesNullableByDefault() {
return false;
}
}

View File

@ -23,9 +23,13 @@
*/
package org.hibernate.metamodel.internal.source.annotations;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.relational.ForeignKey;
import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.metamodel.spi.source.PluralAttributeKeySource;
@ -33,37 +37,52 @@ import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
* @author Hardy Ferentschik
* @author Strong Liu <stliu@hibernate.org>
*/
public class PluralAttributeKeySourceImpl implements PluralAttributeKeySource {
private final PluralAssociationAttribute attribute;
private final ForeignKey.ReferentialAction deleteAction;
public PluralAttributeKeySourceImpl(PluralAssociationAttribute attribute) {
this.attribute = attribute;
this.deleteAction = attribute.getOnDeleteAction() == OnDeleteAction.CASCADE
? ForeignKey.ReferentialAction.CASCADE : ForeignKey.ReferentialAction.NO_ACTION;
}
@Override
public List<RelationalValueSource> getValueSources() {
// TODO
return Collections.emptyList();
List<RelationalValueSource> valueSources = new ArrayList<RelationalValueSource>();
if ( !attribute.getColumnValues().isEmpty() ) {
for ( Column columnValues : attribute.getColumnValues() ) {
valueSources.add( new ColumnSourceImpl( attribute, null, columnValues ) );
}
}
return valueSources;
}
@Override
public ForeignKey.ReferentialAction getOnDeleteAction() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return deleteAction;
}
@Override
public boolean areValuesIncludedInInsertByDefault() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return true;
}
@Override
public boolean areValuesIncludedInUpdateByDefault() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return false;
}
@Override
public boolean areValuesNullableByDefault() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return true;
}
@Override
public String getExplicitForeignKeyName() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@ -89,5 +108,3 @@ public class PluralAttributeKeySourceImpl implements PluralAttributeKeySource {
}
}
}

View File

@ -27,83 +27,108 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.CascadeType;
import org.hibernate.FetchMode;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHelper;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.ManyToAnyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.PluralAttributeElementNature;
import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.Orderable;
import org.hibernate.metamodel.spi.source.PluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.PluralAttributeKeySource;
import org.hibernate.metamodel.spi.source.PluralAttributeNature;
import org.hibernate.metamodel.spi.source.PluralAttributeSource;
import org.hibernate.metamodel.spi.source.Sortable;
import org.hibernate.metamodel.spi.source.TableSpecificationSource;
/**
* @author Hardy Ferentschik
*/
public class PluralAttributeSourceImpl implements PluralAttributeSource {
public class PluralAttributeSourceImpl implements PluralAttributeSource, Orderable, Sortable {
private final PluralAssociationAttribute attribute;
private final PluralAttributeNature nature;
private final Nature nature;
private final ExplicitHibernateTypeSource typeSource;
private final PluralAttributeKeySource keySource;
private final PluralAttributeElementSource elementSource;
public PluralAttributeSourceImpl(PluralAssociationAttribute attribute) {
public PluralAttributeSourceImpl(final PluralAssociationAttribute attribute) {
this.attribute = attribute;
this.nature = resolveAttributeNature();
this.keySource = new PluralAttributeKeySourceImpl( attribute );
this.elementSource = determineElementSource();
this.typeSource = new ExplicitHibernateTypeSource() {
@Override
public String getName() {
return attribute.getHibernateTypeResolver().getExplicitHibernateTypeName();
}
@Override
public Map<String, String> getParameters() {
return attribute.getHibernateTypeResolver().getExplicitHibernateTypeParameters();
}
};
}
private PluralAttributeNature resolveAttributeNature() {
private Nature resolveAttributeNature() {
if ( Map.class.isAssignableFrom( attribute.getAttributeType() ) ) {
return PluralAttributeNature.MAP;
return PluralAttributeSource.Nature.MAP;
}
else if ( List.class.isAssignableFrom( attribute.getAttributeType() ) ) {
return PluralAttributeNature.LIST;
return PluralAttributeSource.Nature.LIST;
}
else if ( Set.class.isAssignableFrom( attribute.getAttributeType() ) ) {
return PluralAttributeNature.SET;
return PluralAttributeSource.Nature.SET;
}
else {
return PluralAttributeNature.BAG;
return PluralAttributeSource.Nature.BAG;
}
}
@Override
public PluralAttributeNature getPluralAttributeNature() {
public Nature getNature() {
return nature;
}
@Override
public PluralAttributeKeySource getKeySource() {
return new PluralAttributeKeySourceImpl( );
public PluralAttributeElementSource getElementSource() {
return elementSource;
}
@Override
public PluralAttributeElementSource getElementSource() {
switch ( attribute.getAttributeNature() ) {
private PluralAttributeElementSource determineElementSource (){
switch ( attribute.getNature() ) {
case MANY_TO_MANY:
return new ManyToManyPluralAttributeElementSourceImpl( attribute );
case MANY_TO_ANY:
return new ManyToAnyPluralAttributeElementSourceImpl();
return new ManyToAnyPluralAttributeElementSourceImpl( attribute );
case ONE_TO_MANY:
return new OneToManyPluralAttributeElementSourceImpl( attribute );
}
return null;
throw new AssertionError( "unexpected attribute nature" );
}
@Override
public PluralAttributeKeySource getKeySource() {
return keySource;
}
@Override
public TableSpecificationSource getCollectionTableSpecificationSource() {
return null; //To change body of implemented methods use File | Settings | File Templates.
// todo see org.hibernate.metamodel.internal.Binder#bindOneToManyCollectionKey
return null;
}
@Override
public String getCollectionTableComment() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return null;
}
@Override
@ -128,7 +153,7 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
@Override
public boolean isInverse() {
return attribute.getMappedBy() == null;
return attribute.getMappedBy() != null;
}
@Override
@ -168,17 +193,17 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
@Override
public ExplicitHibernateTypeSource getTypeInformation() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return typeSource;
}
@Override
public String getPropertyAccessorName() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return attribute.getAccessType();
}
@Override
public boolean isIncludedInOptimisticLocking() {
return false; //To change body of implemented methods use File | Settings | File Templates.
return attribute.isOptimisticLockable();
}
@Override
@ -192,6 +217,26 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
return attribute.getFetchMode();
}
@Override
public String getOrder() {
return attribute.getOrderBy();
}
@Override
public boolean isOrdered() {
return StringHelper.isNotEmpty( getOrder() );
}
@Override
public String getComparatorName() {
return attribute.getComparatorName();
}
@Override
public boolean isSorted() {
return attribute.isSorted();
}
@Override
public FetchTiming getFetchTiming() {
if ( attribute.isExtraLazy() ) {
@ -207,17 +252,55 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource {
public FetchStyle getFetchStyle() {
return attribute.getFetchStyle();
}
public Iterable<CascadeStyle> interpretCascadeStyles(Set<CascadeType> cascadeTypes) {
return EnumConversionHelper.cascadeTypeToCascadeStyleSet( cascadeTypes, attribute.getContext() );
private class ManyToAnyPluralAttributeElementSourceImpl implements ManyToAnyPluralAttributeElementSource {
@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
private class OneToManyPluralAttributeElementSourceImpl implements OneToManyPluralAttributeElementSource {
private final PluralAssociationAttribute attribute;
private OneToManyPluralAttributeElementSourceImpl(PluralAssociationAttribute attribute) {
this.attribute = attribute;
}
@Override
public PluralAttributeElementNature getNature() {
return null; //To change body of implemented methods use File | Settings | File Templates.
public String getReferencedEntityName() {
return attribute.getReferencedEntityType();
}
@Override
public boolean isNotFoundAnException() {
return !attribute.isIgnoreNotFound();
}
@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return interpretCascadeStyles( attribute.getCascadeTypes() );
}
@Override
public Nature getNature() {
return Nature.ONE_TO_MANY;
}
}
private class ManyToAnyPluralAttributeElementSourceImpl implements ManyToAnyPluralAttributeElementSource {
private final PluralAssociationAttribute attribute;
private ManyToAnyPluralAttributeElementSourceImpl(PluralAssociationAttribute attribute) {
this.attribute = attribute;
}
@Override
public Iterable<CascadeStyle> getCascadeStyles() {
return interpretCascadeStyles( attribute.getCascadeTypes() );
}
@Override
public Nature getNature() {
return Nature.MANY_TO_ANY;
}
}
}

View File

@ -36,7 +36,6 @@ import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
import org.hibernate.metamodel.spi.source.SingularAttributeNature;
import org.hibernate.metamodel.spi.source.SingularAttributeSource;
/**
@ -115,8 +114,8 @@ public class SingularAttributeSourceImpl implements SingularAttributeSource {
}
@Override
public SingularAttributeNature getNature() {
return SingularAttributeNature.BASIC;
public Nature getNature() {
return Nature.BASIC;
}
@Override

View File

@ -40,7 +40,6 @@ import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource;
import org.hibernate.metamodel.spi.source.SingularAttributeNature;
import org.hibernate.metamodel.spi.source.ToOneAttributeSource;
/**
@ -53,12 +52,13 @@ public class ToOneAttributeSourceImpl extends SingularAttributeSourceImpl implem
public ToOneAttributeSourceImpl(AssociationAttribute associationAttribute) {
super( associationAttribute );
this.associationAttribute = associationAttribute;
this.cascadeStyles = EnumConversionHelper.cascadeTypeToCascadeStyleSet( associationAttribute.getCascadeTypes() );
this.cascadeStyles = EnumConversionHelper.cascadeTypeToCascadeStyleSet( associationAttribute.getCascadeTypes(), associationAttribute.getContext() );
}
@Override
public SingularAttributeNature getNature() {
return SingularAttributeNature.MANY_TO_ONE;
public Nature getNature() {
return Nature.MANY_TO_ONE;
}
@Override

View File

@ -74,45 +74,20 @@ public class AssociationAttribute extends MappedAttribute {
public static AssociationAttribute createAssociationAttribute(
String name,
Class<?> attributeType,
AttributeNature attributeNature,
Nature attributeNature,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
return createAssociationAttribute(
name,
attributeType,
attributeType,
attributeNature,
accessType,
annotations,
context
);
return new AssociationAttribute( name, attributeType, attributeType, attributeNature, accessType, annotations, context );
}
public static AssociationAttribute createAssociationAttribute(
String name,
Class<?> attributeType,
Class<?> referencedAttributeType,
AttributeNature attributeNature,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
return new AssociationAttribute(
name,
attributeType,
referencedAttributeType,
attributeNature,
accessType,
annotations,
context
);
}
AssociationAttribute(
String name,
Class<?> attributeType,
Class<?> referencedAttributeType,
AttributeNature attributeNature,
Nature attributeNature,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
@ -138,7 +113,7 @@ public class AssociationAttribute extends MappedAttribute {
this.mapsId = referencedIdAttributeName != null;
}
public boolean ignoreNotFound() {
public boolean isIgnoreNotFound() {
return ignoreNotFound;
}
@ -341,8 +316,8 @@ public class AssociationAttribute extends MappedAttribute {
return null;
}
if ( !( AttributeNature.MANY_TO_ONE.equals( getAttributeNature() ) || AttributeNature.MANY_TO_ONE
.equals( getAttributeNature() ) ) ) {
if ( !( Nature.MANY_TO_ONE.equals( getNature() ) || Nature.MANY_TO_ONE
.equals( getNature() ) ) ) {
throw new MappingException(
"@MapsId can only be specified on a many-to-one or one-to-one associations",
getContext().getOrigin()

View File

@ -1,57 +0,0 @@
/*
* 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.internal.source.annotations.attribute;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
/**
* An enum defining the type of a mapped attribute from the JPA perspective.
*
* @author Hardy Ferentschik
*/
public enum AttributeNature {
BASIC( JPADotNames.BASIC ),
ONE_TO_ONE( JPADotNames.ONE_TO_ONE ),
ONE_TO_MANY( JPADotNames.ONE_TO_MANY ),
MANY_TO_ONE( JPADotNames.MANY_TO_ONE ),
MANY_TO_MANY( JPADotNames.MANY_TO_MANY ),
MANY_TO_ANY( HibernateDotNames.MANY_TO_ANY ),
ELEMENT_COLLECTION_BASIC( JPADotNames.ELEMENT_COLLECTION ),
ELEMENT_COLLECTION_EMBEDDABLE( JPADotNames.ELEMENT_COLLECTION ),
EMBEDDED_ID( JPADotNames.EMBEDDED_ID ),
EMBEDDED( JPADotNames.EMBEDDED );
private final DotName annotationDotName;
AttributeNature(DotName annotationDotName) {
this.annotationDotName = annotationDotName;
}
public DotName getAnnotationDotName() {
return annotationDotName;
}
}

View File

@ -23,14 +23,14 @@
*/
package org.hibernate.metamodel.internal.source.annotations.attribute;
import javax.persistence.FetchType;
import javax.persistence.GenerationType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.FetchType;
import javax.persistence.GenerationType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
@ -101,7 +101,7 @@ public class BasicAttribute extends MappedAttribute {
public static BasicAttribute createSimpleAttribute(String name,
Class<?> attributeType,
AttributeNature attributeNature,
Nature attributeNature,
Map<DotName, List<AnnotationInstance>> annotations,
String accessType,
EntityBindingContext context) {
@ -110,7 +110,7 @@ public class BasicAttribute extends MappedAttribute {
BasicAttribute(String name,
Class<?> attributeType,
AttributeNature attributeNature,
Nature attributeNature,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {

View File

@ -32,11 +32,11 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.hibernate.mapping.PropertyGeneration;
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
/**
@ -63,7 +63,7 @@ public abstract class MappedAttribute implements Comparable<MappedAttribute> {
/**
* The nature of the attribute
*/
AttributeNature attributeNature;
Nature attributeNature;
/**
* The access type for this property. At the moment this is either 'field' or 'property', but Hibernate
@ -104,7 +104,7 @@ public abstract class MappedAttribute implements Comparable<MappedAttribute> {
*/
private final EntityBindingContext context;
MappedAttribute(String name, Class<?> attributeType, AttributeNature attributeNature,
MappedAttribute(String name, Class<?> attributeType, Nature attributeNature,
String accessType, Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
this.context = context;
@ -168,7 +168,7 @@ public abstract class MappedAttribute implements Comparable<MappedAttribute> {
this.naturalIdMutability = naturalIdMutability;
}
public AttributeNature getAttributeNature() {
public Nature getNature() {
return attributeNature;
}
@ -285,6 +285,33 @@ public abstract class MappedAttribute implements Comparable<MappedAttribute> {
}
return checkCondition;
}
/**
* An enum defining the type of a mapped attribute.
*
* @author Hardy Ferentschik
*/
public static enum Nature {
BASIC( JPADotNames.BASIC ),
ONE_TO_ONE( JPADotNames.ONE_TO_ONE ),
ONE_TO_MANY( JPADotNames.ONE_TO_MANY ),
MANY_TO_ONE( JPADotNames.MANY_TO_ONE ),
MANY_TO_MANY( JPADotNames.MANY_TO_MANY ),
MANY_TO_ANY( HibernateDotNames.MANY_TO_ANY ),
ELEMENT_COLLECTION_BASIC( JPADotNames.ELEMENT_COLLECTION ),
ELEMENT_COLLECTION_EMBEDDABLE( JPADotNames.ELEMENT_COLLECTION ),
EMBEDDED_ID( JPADotNames.EMBEDDED_ID ),
EMBEDDED( JPADotNames.EMBEDDED );
private final DotName annotationDotName;
Nature(DotName annotationDotName) {
this.annotationDotName = annotationDotName;
}
public DotName getAnnotationDotName() {
return annotationDotName;
}
}
}

View File

@ -33,6 +33,8 @@ import org.jboss.jandex.DotName;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.SortType;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.AnnotationParserHelper;
@ -41,15 +43,19 @@ import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.Caching;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.source.MappingException;
/**
* Represents an collection (collection, list, set, map) association attribute.
*
* @author Hardy Ferentschik
* @author Strong Liu
*/
public class PluralAssociationAttribute extends AssociationAttribute {
private final String whereClause;
private final String orderBy;
private final boolean sorted;
private final String comparatorName;
private final Caching caching;
private final String customPersister;
private final String customLoaderName;
@ -59,6 +65,8 @@ public class PluralAssociationAttribute extends AssociationAttribute {
private final CustomSQL customDeleteAll;
private final ClassInfo entityClassInfo;
private final boolean isExtraLazy;
private final OnDeleteAction onDeleteAction;
private final boolean isIndexed;
// Used for the non-owning side of a ManyToMany relationship
private final String inverseForeignKeyName;
@ -68,7 +76,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
String name,
Class<?> attributeType,
Class<?> referencedAttributeType,
AttributeNature attributeNature,
Nature attributeNature,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
@ -132,12 +140,27 @@ public class PluralAssociationAttribute extends AssociationAttribute {
sb.append( '}' );
return sb.toString();
}
public OnDeleteAction getOnDeleteAction() {
return onDeleteAction;
}
public String getComparatorName() {
return comparatorName;
}
public boolean isSorted() {
return sorted;
}
public boolean isIndexed() {
return isIndexed;
}
private PluralAssociationAttribute(ClassInfo entityClassInfo,
String name,
Class<?> attributeType,
Class<?> referencedAttributeType,
AttributeNature associationType,
Nature associationType,
String accessType,
Map<DotName, List<AnnotationInstance>> annotations,
EntityBindingContext context) {
@ -162,6 +185,48 @@ public class PluralAssociationAttribute extends AssociationAttribute {
this.customDeleteAll = AnnotationParserHelper.processCustomSqlAnnotation(
HibernateDotNames.SQL_DELETE_ALL, annotations()
);
this.onDeleteAction = determineOnDeleteAction();
final AnnotationInstance sortAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT );
if ( sortAnnotation == null ) {
this.sorted = false;
this.comparatorName = null;
}
else {
final SortType sortType = JandexHelper.getEnumValue( sortAnnotation, "type", SortType.class );
this.sorted = sortType != SortType.UNSORTED;
if ( this.sorted && sortType == SortType.COMPARATOR ) {
String comparatorName = JandexHelper.getValue( sortAnnotation, "comparator", String.class );
if ( StringHelper.isEmpty( comparatorName ) ) {
throw new MappingException(
"Comparator class must be provided when using SortType.COMPARATOR.",
getContext().getOrigin()
);
}
this.comparatorName = comparatorName;
}
else {
this.comparatorName = null;
}
}
AnnotationInstance orderColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ORDER_COLUMN );
AnnotationInstance indexColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.INDEX_COLUMN );
this.isIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null;
}
private OnDeleteAction determineOnDeleteAction() {
OnDeleteAction action = null;
final AnnotationInstance onDeleteAnnotation = JandexHelper.getSingleAnnotation(
annotations(),
HibernateDotNames.ON_DELETE
);
if ( onDeleteAnnotation != null ) {
action = JandexHelper.getValue( onDeleteAnnotation, "action", OnDeleteAction.class );
}
return action;
}
private String determineCustomLoaderName() {
@ -209,12 +274,12 @@ public class PluralAssociationAttribute extends AssociationAttribute {
HibernateDotNames.LAZY_COLLECTION
);
if ( lazyCollectionAnnotationInstance != null ) {
LazyCollectionOption option = JandexHelper.getEnumValue(
lazyOption = JandexHelper.getEnumValue(
lazyCollectionAnnotationInstance,
"value",
LazyCollectionOption.class
);
return option == LazyCollectionOption.TRUE;
return lazyOption == LazyCollectionOption.TRUE;
}
return lazy;

View File

@ -30,9 +30,9 @@ import java.util.Map;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
/**
* Type Resolver which checks {@link org.hibernate.annotations.Type} to find the type info.

View File

@ -32,9 +32,9 @@ import org.jboss.jandex.AnnotationInstance;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.type.EnumType;
/**

View File

@ -25,7 +25,6 @@ package org.hibernate.metamodel.internal.source.annotations.attribute.type;
import java.util.Map;
import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver;
import org.hibernate.metamodel.spi.source.ExplicitHibernateTypeSource;
/**

View File

@ -33,9 +33,9 @@ import java.util.Map;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.type.CharacterArrayClobType;
import org.hibernate.type.PrimitiveCharacterArrayClobType;
import org.hibernate.type.SerializableToBlobType;

View File

@ -33,9 +33,9 @@ import org.jboss.jandex.AnnotationInstance;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
import org.hibernate.type.StandardBasicTypes;
/**

View File

@ -57,9 +57,9 @@ import org.hibernate.HibernateException;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeNature;
import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride;
import org.hibernate.metamodel.internal.source.annotations.attribute.BasicAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
@ -433,7 +433,7 @@ public class ConfiguredClass {
classInfo, member.getName()
);
AttributeNature attributeNature = determineAttributeNature( annotations, referencedEntityType );
MappedAttribute.Nature attributeNature = determineAttributeNature( annotations, referencedEntityType );
String accessTypeString = accessType.toString().toLowerCase();
switch ( attributeNature ) {
case BASIC: {
@ -570,39 +570,38 @@ public class ConfiguredClass {
*
* @return an instance of the {@code AttributeType} enum
*/
private AttributeNature determineAttributeNature(Map<DotName, List<AnnotationInstance>> annotations,
Class<?> referencedCollectionType) {
EnumMap<AttributeNature, AnnotationInstance> discoveredAttributeTypes =
new EnumMap<AttributeNature, AnnotationInstance>( AttributeNature.class );
private MappedAttribute.Nature determineAttributeNature(Map<DotName, List<AnnotationInstance>> annotations, Class<?> referencedCollectionType) {
EnumMap<MappedAttribute.Nature, AnnotationInstance> discoveredAttributeTypes =
new EnumMap<MappedAttribute.Nature, AnnotationInstance>( MappedAttribute.Nature.class );
AnnotationInstance oneToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_ONE );
if ( oneToOne != null ) {
discoveredAttributeTypes.put( AttributeNature.ONE_TO_ONE, oneToOne );
discoveredAttributeTypes.put( MappedAttribute.Nature.ONE_TO_ONE, oneToOne );
}
AnnotationInstance oneToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ONE_TO_MANY );
if ( oneToMany != null ) {
discoveredAttributeTypes.put( AttributeNature.ONE_TO_MANY, oneToMany );
discoveredAttributeTypes.put( MappedAttribute.Nature.ONE_TO_MANY, oneToMany );
}
AnnotationInstance manyToOne = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_ONE );
if ( manyToOne != null ) {
discoveredAttributeTypes.put( AttributeNature.MANY_TO_ONE, manyToOne );
discoveredAttributeTypes.put( MappedAttribute.Nature.MANY_TO_ONE, manyToOne );
}
AnnotationInstance manyToMany = JandexHelper.getSingleAnnotation( annotations, JPADotNames.MANY_TO_MANY );
if ( manyToMany != null ) {
discoveredAttributeTypes.put( AttributeNature.MANY_TO_MANY, manyToMany );
discoveredAttributeTypes.put( MappedAttribute.Nature.MANY_TO_MANY, manyToMany );
}
AnnotationInstance embedded = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED );
if ( embedded != null ) {
discoveredAttributeTypes.put( AttributeNature.EMBEDDED, embedded );
discoveredAttributeTypes.put( MappedAttribute.Nature.EMBEDDED, embedded );
}
AnnotationInstance embeddedId = JandexHelper.getSingleAnnotation( annotations, JPADotNames.EMBEDDED_ID );
if ( embeddedId != null ) {
discoveredAttributeTypes.put( AttributeNature.EMBEDDED_ID, embeddedId );
discoveredAttributeTypes.put( MappedAttribute.Nature.EMBEDDED_ID, embeddedId );
}
AnnotationInstance elementCollection = JandexHelper.getSingleAnnotation(
@ -616,19 +615,17 @@ public class ConfiguredClass {
)
);
if ( classInfo.annotations().get( JPADotNames.EMBEDDABLE ) != null ) {
discoveredAttributeTypes.put( AttributeNature.ELEMENT_COLLECTION_EMBEDDABLE, elementCollection );
discoveredAttributeTypes.put( MappedAttribute.Nature.ELEMENT_COLLECTION_EMBEDDABLE, elementCollection );
}
else {
discoveredAttributeTypes.put( AttributeNature.ELEMENT_COLLECTION_BASIC, elementCollection );
discoveredAttributeTypes.put( MappedAttribute.Nature.ELEMENT_COLLECTION_BASIC, elementCollection );
}
}
int size = discoveredAttributeTypes.size();
switch ( size ) {
case 0:
return AttributeNature.BASIC;
return MappedAttribute.Nature.BASIC;
case 1:
return discoveredAttributeTypes.keySet().iterator().next();
default:

View File

@ -26,16 +26,13 @@ package org.hibernate.metamodel.internal.source.annotations.entity;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.persistence.AccessType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;

View File

@ -33,25 +33,24 @@ import com.fasterxml.classmate.ResolvedType;
import com.fasterxml.classmate.ResolvedTypeWithMembers;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.hibernate.cfg.NamingStrategy;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.jaxb.spi.Origin;
import org.hibernate.jaxb.spi.SourceType;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.metamodel.internal.source.annotations.IdentifierGeneratorSourceContainer;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.spi.binding.IdGenerator;
import org.hibernate.metamodel.spi.domain.Type;
import org.hibernate.metamodel.spi.source.IdentifierGeneratorSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.MappingDefaults;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.MetadataImplementor;
import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext;
import org.hibernate.service.ServiceRegistry;
/**

View File

@ -23,14 +23,13 @@
*/
package org.hibernate.metamodel.internal.source.annotations.global;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger;
import org.hibernate.annotations.GenericGenerator;

View File

@ -23,16 +23,15 @@
*/
package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.Collection;
import java.util.HashMap;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import java.util.Collection;
import java.util.HashMap;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;

View File

@ -33,7 +33,6 @@ import java.util.Map;
import java.util.Set;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger;
import org.hibernate.LockMode;

View File

@ -26,7 +26,6 @@ package org.hibernate.metamodel.internal.source.annotations.global;
import java.util.Collection;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.logging.Logger;
import org.hibernate.AnnotationException;

Some files were not shown because too many files have changed in this diff Show More