From 8fe5460ec03942e974d4aae7d9060e20bab7f990 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Sun, 24 Nov 2013 20:07:37 -0600 Subject: [PATCH] HHH-8741 - More checkstyle cleanups --- .../event/internal/OnUpdateVisitor.java | 4 +- .../hibernate/hql/internal/ast/HqlParser.java | 2 +- .../hql/internal/ast/QueryTranslatorImpl.java | 2 +- .../ast/tree/AssignmentSpecification.java | 4 +- .../tree/BinaryArithmeticOperatorNode.java | 14 +- .../ast/tree/BinaryLogicOperatorNode.java | 4 +- .../hql/internal/ast/tree/DotNode.java | 10 +- .../internal/ast/tree/FromElementType.java | 16 +- .../hql/internal/ast/tree/IdentNode.java | 2 +- ...ompositeNestedGeneratedValueGenerator.java | 15 +- .../org/hibernate/id/ForeignGenerator.java | 8 +- .../org/hibernate/internal/SessionImpl.java | 187 +++++++++++++----- .../hibernate/internal/TypeLocatorImpl.java | 32 +-- .../ConcurrentReferenceHashMap.java | 53 +++++ .../internal/util/xml/OriginImpl.java | 8 +- .../internal/util/xml/XmlDocumentImpl.java | 8 +- .../loader/DefaultEntityAliases.java | 24 +-- .../criteria/CriteriaQueryTranslator.java | 22 ++- .../build/spi/ReturnGraphTreePrinter.java | 26 ++- .../java/org/hibernate/mapping/Backref.java | 12 +- .../java/org/hibernate/mapping/Component.java | 47 +++-- .../org/hibernate/mapping/FetchProfile.java | 8 +- .../java/org/hibernate/mapping/Formula.java | 3 +- .../org/hibernate/mapping/IndexBackref.java | 10 +- .../java/org/hibernate/mapping/Table.java | 2 +- .../metamodel/relational/DerivedValue.java | 7 +- .../param/NamedParameterSpecification.java | 5 +- .../PositionalParameterSpecification.java | 5 +- .../AbstractCollectionPersister.java | 88 ++++++++- .../property/BackrefPropertyAccessor.java | 47 ++--- .../property/BasicPropertyAccessor.java | 40 ++-- .../property/DirectPropertyAccessor.java | 50 ++--- .../property/EmbeddedPropertyAccessor.java | 59 ++---- .../property/IndexPropertyAccessor.java | 41 ++-- .../org/hibernate/property/MapAccessor.java | 47 ++--- .../org/hibernate/property/NoopAccessor.java | 41 ++-- ...iasToBeanConstructorResultTransformer.java | 7 +- .../AliasToBeanResultTransformer.java | 9 +- .../AliasToEntityMapResultTransformer.java | 8 +- .../AliasedTupleSubsetResultTransformer.java | 5 +- .../DistinctRootEntityResultTransformer.java | 10 +- .../PassThroughResultTransformer.java | 12 +- .../RootEntityResultTransformer.java | 9 +- .../transform/ToListResultTransformer.java | 8 +- .../tuple/entity/AbstractEntityTuplizer.java | 45 +++-- .../entity/DynamicMapEntityTuplizer.java | 65 +----- .../tuple/entity/PojoEntityTuplizer.java | 72 +------ .../org/hibernate/type/BigDecimalType.java | 4 +- .../org/hibernate/type/BigIntegerType.java | 12 +- .../java/org/hibernate/type/BlobType.java | 4 +- .../org/hibernate/type/CollectionType.java | 45 ++++- .../java/org/hibernate/type/EntityType.java | 59 +++--- .../org/hibernate/type/OrderedMapType.java | 4 +- .../org/hibernate/type/OrderedSetType.java | 4 +- .../type/SerializableToBlobType.java | 12 +- .../java/BigIntegerTypeDescriptor.java | 10 +- .../descriptor/sql/BlobTypeDescriptor.java | 107 +++++----- .../java/org/hibernate/test/hql/HQLTest.java | 4 +- .../EntityManagerFactoryBuilderImpl.java | 36 ++-- .../expression/BinaryArithmeticOperation.java | 33 ++-- .../expression/UnaryArithmeticOperation.java | 10 +- .../internal/metamodel/AbstractAttribute.java | 20 +- .../metamodel/PluralAttributeImpl.java | 44 ++--- .../jpa/spi/AbstractEntityManagerImpl.java | 36 ++-- .../AbstractReadWriteAccessStrategy.java | 52 ++--- ...ansactionalEntityRegionAccessStrategy.java | 17 +- 66 files changed, 792 insertions(+), 924 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java b/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java index 48932d6bfd..cefbb167ab 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/OnUpdateVisitor.java @@ -47,9 +47,7 @@ public class OnUpdateVisitor extends ReattachVisitor { super( session, key, owner ); } - /** - * {@inheritDoc} - */ + @Override Object processCollection(Object collection, CollectionType type) throws HibernateException { if ( collection == CollectionType.UNFETCHED_COLLECTION ) { diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlParser.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlParser.java index 51962f1421..79b5e44711 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlParser.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/HqlParser.java @@ -479,7 +479,7 @@ public final class HqlParser extends HqlBaseParser { return treatMap == null ? Collections.>emptyMap() : treatMap; } - static public void panic() { + public static void panic() { //overriden to avoid System.exit throw new QueryException( "Parser: panic" ); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java index ceda7f4a2f..a2e3a85443 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/QueryTranslatorImpl.java @@ -606,7 +606,7 @@ public class QueryTranslatorImpl implements FilterTranslator { public void visit(AST node) { if ( dotRoot != null ) { // we are already processing a dot-structure - if ( ASTUtil.isSubtreeChild(dotRoot, node) ) { + if ( ASTUtil.isSubtreeChild( dotRoot, node ) ) { return; } // we are now at a new tree level diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AssignmentSpecification.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AssignmentSpecification.java index 5b98f9109a..3d0d89684c 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AssignmentSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/AssignmentSpecification.java @@ -95,7 +95,7 @@ public class AssignmentSpecification { hqlParameters = new ParameterSpecification[0]; } else if ( isParam( rhs ) ) { - hqlParameters = new ParameterSpecification[] { ( ( ParameterNode ) rhs ).getHqlParameterSpecification() }; + hqlParameters = new ParameterSpecification[] { ( (ParameterNode) rhs ).getHqlParameterSpecification() }; } else { List parameterList = ASTUtil.collectChildren( @@ -110,7 +110,7 @@ public class AssignmentSpecification { Iterator itr = parameterList.iterator(); int i = 0; while( itr.hasNext() ) { - hqlParameters[i++] = ( ( ParameterNode ) itr.next() ).getHqlParameterSpecification(); + hqlParameters[i++] = ( (ParameterNode) itr.next() ).getHqlParameterSpecification(); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java index 4e54bf9550..60e447c38c 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryArithmeticOperatorNode.java @@ -48,8 +48,8 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple throw new SemanticException( "right-hand operand of a binary operator was null" ); } - final Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null; - final Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null; + final Type lhType = ( lhs instanceof SqlNode ) ? ( (SqlNode) lhs ).getDataType() : null; + final Type rhType = ( rhs instanceof SqlNode ) ? ( (SqlNode) rhs ).getDataType() : null; if ( ExpectedTypeAwareNode.class.isAssignableFrom( lhs.getClass() ) && rhType != null ) { Type expectedType = null; @@ -84,7 +84,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple else { expectedType = lhType; } - ( ( ExpectedTypeAwareNode ) rhs ).setExpectedType( expectedType ); + ( (ExpectedTypeAwareNode) rhs ).setExpectedType( expectedType ); } } @@ -107,8 +107,8 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple // makes any sense. Node lhs = getLeftHandOperand(); Node rhs = getRightHandOperand(); - Type lhType = ( lhs instanceof SqlNode ) ? ( ( SqlNode ) lhs ).getDataType() : null; - Type rhType = ( rhs instanceof SqlNode ) ? ( ( SqlNode ) rhs ).getDataType() : null; + Type lhType = ( lhs instanceof SqlNode ) ? ( (SqlNode) lhs ).getDataType() : null; + Type rhType = ( rhs instanceof SqlNode ) ? ( (SqlNode) rhs ).getDataType() : null; if ( isDateTimeType( lhType ) || isDateTimeType( rhType ) ) { return resolveDateTimeArithmeticResultType( lhType, rhType ); } @@ -209,7 +209,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple */ @Override public Node getLeftHandOperand() { - return ( Node ) getFirstChild(); + return (Node) getFirstChild(); } /** @@ -219,7 +219,7 @@ public class BinaryArithmeticOperatorNode extends AbstractSelectExpression imple */ @Override public Node getRightHandOperand() { - return ( Node ) getFirstChild().getNextSibling(); + return (Node) getFirstChild().getNextSibling(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java index 1dddc185dd..709a844c8e 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/BinaryLogicOperatorNode.java @@ -133,12 +133,12 @@ public class BinaryLogicOperatorNode extends HqlSqlWalkerNode implements BinaryO ParameterSpecification lhsEmbeddedCompositeParameterSpecification = getLeftHandOperand() == null || ( !ParameterNode.class.isInstance( getLeftHandOperand() ) ) ? null - : ( ( ParameterNode ) getLeftHandOperand() ).getHqlParameterSpecification(); + : ( (ParameterNode) getLeftHandOperand() ).getHqlParameterSpecification(); ParameterSpecification rhsEmbeddedCompositeParameterSpecification = getRightHandOperand() == null || ( !ParameterNode.class.isInstance( getRightHandOperand() ) ) ? null - : ( ( ParameterNode ) getRightHandOperand() ).getHqlParameterSpecification(); + : ( (ParameterNode) getRightHandOperand() ).getHqlParameterSpecification(); translate( valueElements, diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java index 51fd5c942c..1d4ef4ab24 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/DotNode.java @@ -59,7 +59,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec // todo : obviously get rid of all this junk ;) /////////////////////////////////////////////////////////////////////////// public static boolean useThetaStyleImplicitJoins; - public static boolean REGRESSION_STYLE_JOIN_SUPPRESSION; + public static boolean regressionStyleJoinSuppression; public static interface IllegalCollectionDereferenceExceptionBuilder { public QueryException buildIllegalCollectionDereferenceException( @@ -112,7 +112,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec /** * Fetch join or not. */ - private boolean fetch = false; + private boolean fetch; /** * The type of dereference that hapened @@ -367,9 +367,9 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec // 2) is this a DML statement // 3) we were asked to generate any needed joins (generateJoins==true) *OR* // we are currently processing a select or from clause - // (an additional check is the REGRESSION_STYLE_JOIN_SUPPRESSION check solely intended for the test suite) + // (an additional check is the regressionStyleJoinSuppression check solely intended for the test suite) // - // The REGRESSION_STYLE_JOIN_SUPPRESSION is an additional check + // The regressionStyleJoinSuppression is an additional check // intended solely for use within the test suite. This forces the // implicit join resolution to behave more like the classic parser. // The underlying issue is that classic translator is simply wrong @@ -397,7 +397,7 @@ public class DotNode extends FromReferenceNode implements DisplayableNode, Selec // in non-select queries, the only time we should need to join is if we are in a subquery from clause joinIsNeeded = getWalker().getCurrentStatementType() == SqlTokenTypes.SELECT && getWalker().isInFrom(); } - else if ( REGRESSION_STYLE_JOIN_SUPPRESSION ) { + else if ( regressionStyleJoinSuppression ) { // this is the regression style determination which matches the logic of the classic translator joinIsNeeded = generateJoin && ( !getWalker().isInSelect() || !getWalker().isShallowQuery() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java index 755174714e..81a52dfaa9 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/FromElementType.java @@ -518,9 +518,7 @@ class FromElementType { } private class SpecialManyToManyCollectionPropertyMapping implements PropertyMapping { - /** - * {@inheritDoc} - */ + @Override public Type getType() { return queryableCollection.getCollectionType(); } @@ -533,17 +531,13 @@ class FromElementType { } } - /** - * {@inheritDoc} - */ + @Override public Type toType(String propertyName) throws QueryException { validate( propertyName ); return queryableCollection.getIndexType(); } - /** - * {@inheritDoc} - */ + @Override public String[] toColumns(String alias, String propertyName) throws QueryException { validate( propertyName ); final String joinTableAlias = joinSequence.getFirstJoin().getAlias(); @@ -566,9 +560,7 @@ class FromElementType { } } - /** - * {@inheritDoc} - */ + @Override public String[] toColumns(String propertyName) throws QueryException, UnsupportedOperationException { validate( propertyName ); return queryableCollection.toColumns( propertyName ); diff --git a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java index 173b58bab6..88d33dd61b 100644 --- a/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java +++ b/hibernate-core/src/main/java/org/hibernate/hql/internal/ast/tree/IdentNode.java @@ -55,7 +55,7 @@ public class IdentNode extends FromReferenceNode implements SelectExpression { COMPONENT_REF } - private boolean nakedPropertyRef = false; + private boolean nakedPropertyRef; public void resolveIndex(AST parent) throws SemanticException { // An ident node can represent an index expression if the ident diff --git a/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java index f247bedc34..a924daaf91 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/CompositeNestedGeneratedValueGenerator.java @@ -112,25 +112,22 @@ public class CompositeNestedGeneratedValueGenerator implements IdentifierGenerat generationPlans.add( plan ); } + @Override public Serializable generate(SessionImplementor session, Object object) throws HibernateException { final Serializable context = generationContextLocator.locateGenerationContext( session, object ); - Iterator itr = generationPlans.iterator(); - while ( itr.hasNext() ) { - final GenerationPlan plan = (GenerationPlan) itr.next(); + for ( Object generationPlan : generationPlans ) { + final GenerationPlan plan = (GenerationPlan) generationPlan; plan.execute( session, object, context ); } return context; } - /** - * {@inheritDoc} - */ + @Override public void registerPersistentGenerators(Map generatorMap) { - final Iterator itr = generationPlans.iterator(); - while ( itr.hasNext() ) { - final GenerationPlan plan = (GenerationPlan) itr.next(); + for ( Object generationPlan : generationPlans ) { + final GenerationPlan plan = (GenerationPlan) generationPlan; plan.registerPersistentGenerators( generatorMap ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java b/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java index 5ca1592f94..5ce6fd5ca7 100644 --- a/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java +++ b/hibernate-core/src/main/java/org/hibernate/id/ForeignGenerator.java @@ -79,9 +79,7 @@ public class ForeignGenerator implements IdentifierGenerator, Configurable { return getEntityName() + '.' + getPropertyName(); } - /** - * {@inheritDoc} - */ + @Override public void configure(Type type, Properties params, Dialect d) { propertyName = params.getProperty( "property" ); entityName = params.getProperty( ENTITY_NAME ); @@ -90,9 +88,7 @@ public class ForeignGenerator implements IdentifierGenerator, Configurable { } } - /** - * {@inheritDoc} - */ + @Override public Serializable generate(SessionImplementor sessionImplementor, Object object) { Session session = ( Session ) sessionImplementor; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 1318d54b85..411a5a95ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -323,6 +323,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return new SharedSessionBuilderImpl( this ); } + @Override public void clear() { errorIfClosed(); // Do not call checkTransactionSynchStatus() here -- if a delayed @@ -341,11 +342,13 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public long getTimestamp() { checkTransactionSynchStatus(); return timestamp; } + @Override public Connection close() throws HibernateException { LOG.trace( "Closing session" ); if ( isClosed() ) { @@ -377,6 +380,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public ConnectionReleaseMode getConnectionReleaseMode() { return connectionReleaseMode; } @@ -386,23 +390,28 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return autoJoinTransactions; } + @Override public boolean isAutoCloseSessionEnabled() { return autoCloseSessionEnabled; } + @Override public boolean isOpen() { checkTransactionSynchStatus(); return !isClosed(); } + @Override public boolean isFlushModeNever() { return FlushMode.isManualFlushMode( getFlushMode() ); } + @Override public boolean isFlushBeforeCompletionEnabled() { return flushBeforeCompletionEnabled; } + @Override public void managedFlush() { if ( isClosed() ) { LOG.trace( "Skipping auto-flush due to session closed" ); @@ -425,21 +434,25 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public void managedClose() { LOG.trace( "Automatically closing session" ); close(); } + @Override public Connection connection() throws HibernateException { errorIfClosed(); return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().getConnection(); } + @Override public boolean isConnected() { checkTransactionSynchStatus(); return !isClosed() && transactionCoordinator.getJdbcCoordinator().getLogicalConnection().isOpen(); } + @Override public boolean isTransactionInProgress() { checkTransactionSynchStatus(); return !isClosed() && transactionCoordinator.isTransactionInProgress(); @@ -461,6 +474,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualReconnect( conn ); } + @Override public void setAutoClear(boolean enabled) { errorIfClosed(); autoClear = enabled; @@ -584,6 +598,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc persistenceContext.clear(); } + @Override public LockMode getCurrentLockMode(Object object) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -610,6 +625,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return e.getLockMode(); } + @Override public Object getEntityUsingInterceptor(EntityKey key) throws HibernateException { errorIfClosed(); // todo : should this get moved to PersistentContext? @@ -646,10 +662,12 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // saveOrUpdate() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void saveOrUpdate(Object object) throws HibernateException { saveOrUpdate( null, object ); } + @Override public void saveOrUpdate(String entityName, Object obj) throws HibernateException { fireSaveOrUpdate( new SaveOrUpdateEvent( entityName, obj, this ) ); } @@ -675,10 +693,12 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // save() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public Serializable save(Object obj) throws HibernateException { return save( null, obj ); } + @Override public Serializable save(String entityName, Object object) throws HibernateException { return fireSave( new SaveOrUpdateEvent( entityName, object, this ) ); } @@ -697,10 +717,12 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // update() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void update(Object obj) throws HibernateException { update( null, obj ); } + @Override public void update(String entityName, Object object) throws HibernateException { fireUpdate( new SaveOrUpdateEvent( entityName, object, this ) ); } @@ -718,14 +740,17 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // lock() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void lock(String entityName, Object object, LockMode lockMode) throws HibernateException { fireLock( new LockEvent( entityName, object, lockMode, this ) ); } + @Override public LockRequest buildLockRequest(LockOptions lockOptions) { return new LockRequestImpl(lockOptions); } + @Override public void lock(Object object, LockMode lockMode) throws HibernateException { fireLock( new LockEvent( object, lockMode, this ) ); } @@ -750,16 +775,18 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // persist() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void persist(String entityName, Object object) throws HibernateException { firePersist( new PersistEvent( entityName, object, this ) ); } + @Override public void persist(Object object) throws HibernateException { persist( null, object ); } - public void persist(String entityName, Object object, Map copiedAlready) - throws HibernateException { + @Override + public void persist(String entityName, Object object, Map copiedAlready) throws HibernateException { firePersist( copiedAlready, new PersistEvent( entityName, object, this ) ); } @@ -794,6 +821,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc persist( null, object ); } + @Override public void persistOnFlush(String entityName, Object object, Map copiedAlready) throws HibernateException { firePersistOnFlush( copiedAlready, new PersistEvent( entityName, object, this ) ); @@ -821,14 +849,17 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // merge() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public Object merge(String entityName, Object object) throws HibernateException { return fireMerge( new MergeEvent( entityName, object, this ) ); } + @Override public Object merge(Object object) throws HibernateException { return merge( null, object ); } + @Override public void merge(String entityName, Object object, Map copiedAlready) throws HibernateException { fireMerge( copiedAlready, new MergeEvent( entityName, object, this ) ); } @@ -856,30 +887,25 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // delete() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - * Delete a persistent object - */ + @Override public void delete(Object object) throws HibernateException { fireDelete( new DeleteEvent( object, this ) ); } - /** - * Delete a persistent object (by explicit entity name) - */ + @Override public void delete(String entityName, Object object) throws HibernateException { fireDelete( new DeleteEvent( entityName, object, this ) ); } - /** - * Delete a persistent object - */ + @Override public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, Set transientEntities) throws HibernateException { fireDelete( new DeleteEvent( entityName, object, isCascadeDeleteEnabled, this ), transientEntities ); } - - // TODO: The removeOrphan concept is a temporary "hack" for HHH-6484. This should be removed once action/task - // ordering is improved. + + @Override public void removeOrphanBeforeUpdates(String entityName, Object child) { + // TODO: The removeOrphan concept is a temporary "hack" for HHH-6484. This should be removed once action/task + // ordering is improved. fireDelete( new DeleteEvent( entityName, child, false, true, this ) ); } @@ -904,23 +930,28 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // load()/get() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void load(Object object, Serializable id) throws HibernateException { LoadEvent event = new LoadEvent(id, object, this); fireLoad( event, LoadEventListener.RELOAD ); } + @Override public Object load(Class entityClass, Serializable id) throws HibernateException { return this.byId( entityClass ).getReference( id ); } + @Override public Object load(String entityName, Serializable id) throws HibernateException { return this.byId( entityName ).getReference( id ); } + @Override public Object get(Class entityClass, Serializable id) throws HibernateException { return this.byId( entityClass ).load( id ); } + @Override public Object get(String entityName, Serializable id) throws HibernateException { return this.byId( entityName ).load( id ); } @@ -930,6 +961,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc * This is only called when lazily initializing a proxy. * Do NOT return a proxy. */ + @Override public Object immediateLoad(String entityName, Serializable id) throws HibernateException { if ( LOG.isDebugEnabled() ) { EntityPersister persister = getFactory().getEntityPersister(entityName); @@ -941,6 +973,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return event.getResult(); } + @Override public Object internalLoad(String entityName, Serializable id, boolean eager, boolean nullable) throws HibernateException { // todo : remove LoadEventListener.LoadType type = nullable @@ -956,34 +989,42 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return event.getResult(); } + @Override public Object load(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException { return this.byId( entityClass ).with( new LockOptions( lockMode ) ).getReference( id ); } + @Override public Object load(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException { return this.byId( entityClass ).with( lockOptions ).getReference( id ); } + @Override public Object load(String entityName, Serializable id, LockMode lockMode) throws HibernateException { return this.byId( entityName ).with( new LockOptions( lockMode ) ).getReference( id ); } + @Override public Object load(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException { return this.byId( entityName ).with( lockOptions ).getReference( id ); } + @Override public Object get(Class entityClass, Serializable id, LockMode lockMode) throws HibernateException { return this.byId( entityClass ).with( new LockOptions( lockMode ) ).load( id ); } + @Override public Object get(Class entityClass, Serializable id, LockOptions lockOptions) throws HibernateException { return this.byId( entityClass ).with( lockOptions ).load( id ); } + @Override public Object get(String entityName, Serializable id, LockMode lockMode) throws HibernateException { return this.byId( entityName ).with( new LockOptions( lockMode ) ).load( id ); } + @Override public Object get(String entityName, Serializable id, LockOptions lockOptions) throws HibernateException { return this.byId( entityName ).with( lockOptions ).load( id ); } @@ -1039,6 +1080,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // refresh() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void refresh(Object object) throws HibernateException { refresh( null, object ); } @@ -1048,18 +1090,22 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc fireRefresh( new RefreshEvent( entityName, object, this ) ); } + @Override public void refresh(Object object, LockMode lockMode) throws HibernateException { fireRefresh( new RefreshEvent( object, lockMode, this ) ); } + @Override public void refresh(Object object, LockOptions lockOptions) throws HibernateException { refresh( null, object, lockOptions ); } + @Override public void refresh(String entityName, Object object, LockOptions lockOptions) throws HibernateException { fireRefresh( new RefreshEvent( entityName, object, lockOptions, this ) ); } + @Override public void refresh(String entityName, Object object, Map refreshedAlready) throws HibernateException { fireRefresh( refreshedAlready, new RefreshEvent( entityName, object, this ) ); } @@ -1085,10 +1131,12 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // replicate() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public void replicate(Object obj, ReplicationMode replicationMode) throws HibernateException { fireReplicate( new ReplicateEvent( obj, replicationMode, this ) ); } + @Override public void replicate(String entityName, Object obj, ReplicationMode replicationMode) throws HibernateException { fireReplicate( new ReplicateEvent( entityName, obj, replicationMode, this ) ); @@ -1110,6 +1158,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc * remove any hard references to the entity that are held by the infrastructure * (references held by application or other persistent instances are okay) */ + @Override public void evict(Object object) throws HibernateException { fireEvict( new EvictEvent( object, this ) ); } @@ -1140,6 +1189,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return event.isFlushRequired(); } + @Override public boolean isDirty() throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1156,6 +1206,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return event.isDirty(); } + @Override public void flush() throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1169,6 +1220,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc delayedAfterCompletion(); } + @Override public void forceFlush(EntityEntry entityEntry) throws HibernateException { errorIfClosed(); if ( LOG.isDebugEnabled() ) { @@ -1187,6 +1239,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc flush(); } + @Override public List list(String query, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1215,6 +1268,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return results; } + @Override public int executeUpdate(String query, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1235,6 +1289,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return result; } + @Override public int executeNativeUpdate(NativeSQLQuerySpecification nativeQuerySpecification, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); @@ -1257,6 +1312,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return result; } + @Override public Iterator iterate(String query, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1274,6 +1330,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public ScrollableResults scroll(String query, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1289,6 +1346,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public Query createFilter(Object collection, String queryString) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1303,6 +1361,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return filter; } + @Override public Query getNamedQuery(String queryName) throws MappingException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1311,6 +1370,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return query; } + @Override public Object instantiate(String entityName, Serializable id) throws HibernateException { return instantiate( factory.getEntityPersister( entityName ), id ); } @@ -1318,6 +1378,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc /** * give the interceptor an opportunity to override the default instantiation */ + @Override public Object instantiate(EntityPersister persister, Serializable id) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1329,6 +1390,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return result; } + @Override public void setFlushMode(FlushMode flushMode) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1336,16 +1398,19 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc this.flushMode = flushMode; } + @Override public FlushMode getFlushMode() { checkTransactionSynchStatus(); return flushMode; } + @Override public CacheMode getCacheMode() { checkTransactionSynchStatus(); return cacheMode; } + @Override public void setCacheMode(CacheMode cacheMode) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1353,11 +1418,13 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc this.cacheMode= cacheMode; } + @Override public Transaction getTransaction() throws HibernateException { errorIfClosed(); return transactionCoordinator.getTransaction(); } + @Override public Transaction beginTransaction() throws HibernateException { errorIfClosed(); Transaction result = getTransaction(); @@ -1365,6 +1432,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return result; } + @Override public EntityPersister getEntityPersister(final String entityName, final Object object) { errorIfClosed(); if (entityName==null) { @@ -1391,6 +1459,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } // not for internal use: + @Override public Serializable getIdentifier(Object object) throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); @@ -1414,6 +1483,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc * Get the id value for an object that is actually associated with the session. This * is a bit stricter than getEntityIdentifierIfNotUnsaved(). */ + @Override public Serializable getContextEntityIdentifier(Object object) { errorIfClosed(); if ( object instanceof HibernateProxy ) { @@ -1479,6 +1549,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return plan; } + @Override public List listFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); @@ -1500,6 +1571,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return results; } + @Override public Iterator iterateFilter(Object collection, String filter, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); @@ -1510,30 +1582,35 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return itr; } + @Override public Criteria createCriteria(Class persistentClass, String alias) { errorIfClosed(); checkTransactionSynchStatus(); return new CriteriaImpl( persistentClass.getName(), alias, this ); } + @Override public Criteria createCriteria(String entityName, String alias) { errorIfClosed(); checkTransactionSynchStatus(); return new CriteriaImpl(entityName, alias, this); } + @Override public Criteria createCriteria(Class persistentClass) { errorIfClosed(); checkTransactionSynchStatus(); return new CriteriaImpl( persistentClass.getName(), this ); } + @Override public Criteria createCriteria(String entityName) { errorIfClosed(); checkTransactionSynchStatus(); return new CriteriaImpl(entityName, this); } + @Override public ScrollableResults scroll(Criteria criteria, ScrollMode scrollMode) { // TODO: Is this guaranteed to always be CriteriaImpl? CriteriaImpl criteriaImpl = (CriteriaImpl) criteria; @@ -1559,6 +1636,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public List list(Criteria criteria) throws HibernateException { // TODO: Is this guaranteed to always be CriteriaImpl? CriteriaImpl criteriaImpl = (CriteriaImpl) criteria; @@ -1680,6 +1758,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return ( OuterJoinLoadable ) persister; } + @Override public boolean contains(Object object) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1710,12 +1789,14 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return entry != null && entry.getStatus() != Status.DELETED && entry.getStatus() != Status.GONE; } + @Override public Query createQuery(String queryString) { errorIfClosed(); checkTransactionSynchStatus(); return super.createQuery( queryString ); } + @Override public SQLQuery createSQLQuery(String sql) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1743,6 +1824,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return super.createStoredProcedureCall( procedureName, resultClasses ); } + @Override public ScrollableResults scrollCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); @@ -1767,6 +1849,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } // basically just an adapted copy of find(CriteriaImpl) + @Override public List listCustomQuery(CustomQuery customQuery, QueryParameters queryParameters) throws HibernateException { errorIfClosed(); @@ -1794,11 +1877,13 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public SessionFactoryImplementor getSessionFactory() { checkTransactionSynchStatus(); return factory; } + @Override public void initializeCollection(PersistentCollection collection, boolean writing) throws HibernateException { errorIfClosed(); @@ -1810,6 +1895,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc delayedAfterCompletion(); } + @Override public String bestGuessEntityName(Object object) { if (object instanceof HibernateProxy) { LazyInitializer initializer = ( ( HibernateProxy ) object ).getHibernateLazyInitializer(); @@ -1829,6 +1915,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } } + @Override public String getEntityName(Object object) { errorIfClosed(); checkTransactionSynchStatus(); @@ -1853,25 +1940,30 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc ); } + @Override public String guessEntityName(Object object) throws HibernateException { errorIfClosed(); return entityNameResolver.resolveEntityName( object ); } + @Override public void cancelQuery() throws HibernateException { errorIfClosed(); getTransactionCoordinator().getJdbcCoordinator().cancelLastQuery(); } + @Override public Interceptor getInterceptor() { checkTransactionSynchStatus(); return interceptor; } + @Override public int getDontFlushFromFind() { return dontFlushFromFind; } + @Override public String toString() { StringBuilder buf = new StringBuilder(500) .append( "SessionImpl(" ); @@ -1886,54 +1978,57 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return buf.append(')').toString(); } + @Override public ActionQueue getActionQueue() { errorIfClosed(); checkTransactionSynchStatus(); return actionQueue; } + @Override public PersistenceContext getPersistenceContext() { errorIfClosed(); checkTransactionSynchStatus(); return persistenceContext; } + @Override public SessionStatistics getStatistics() { checkTransactionSynchStatus(); return new SessionStatisticsImpl(this); } + @Override public boolean isEventSource() { checkTransactionSynchStatus(); return true; } - /** - * {@inheritDoc} - */ + @Override public boolean isDefaultReadOnly() { return persistenceContext.isDefaultReadOnly(); } - /** - * {@inheritDoc} - */ + @Override public void setDefaultReadOnly(boolean defaultReadOnly) { persistenceContext.setDefaultReadOnly( defaultReadOnly ); } + @Override public boolean isReadOnly(Object entityOrProxy) { errorIfClosed(); checkTransactionSynchStatus(); return persistenceContext.isReadOnly( entityOrProxy ); } + @Override public void setReadOnly(Object entity, boolean readOnly) { errorIfClosed(); checkTransactionSynchStatus(); persistenceContext.setReadOnly( entity, readOnly ); } + @Override public void doWork(final Work work) throws HibernateException { WorkExecutorVisitable realWork = new WorkExecutorVisitable() { @Override @@ -1945,6 +2040,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc doWork( realWork ); } + @Override public T doReturningWork(final ReturningWork work) throws HibernateException { WorkExecutorVisitable realWork = new WorkExecutorVisitable() { @Override @@ -1959,6 +2055,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return transactionCoordinator.getJdbcCoordinator().coordinateWork( work ); } + @Override public void afterScrollOperation() { // nothing to do in a stateful session } @@ -1969,59 +2066,48 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc return transactionCoordinator; } + @Override public LoadQueryInfluencers getLoadQueryInfluencers() { return loadQueryInfluencers; } // filter support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - * {@inheritDoc} - */ + @Override public Filter getEnabledFilter(String filterName) { checkTransactionSynchStatus(); return loadQueryInfluencers.getEnabledFilter( filterName ); } - /** - * {@inheritDoc} - */ + @Override public Filter enableFilter(String filterName) { errorIfClosed(); checkTransactionSynchStatus(); return loadQueryInfluencers.enableFilter( filterName ); } - /** - * {@inheritDoc} - */ + @Override public void disableFilter(String filterName) { errorIfClosed(); checkTransactionSynchStatus(); loadQueryInfluencers.disableFilter( filterName ); } - /** - * {@inheritDoc} - */ + @Override public Object getFilterParameterValue(String filterParameterName) { errorIfClosed(); checkTransactionSynchStatus(); return loadQueryInfluencers.getFilterParameterValue( filterParameterName ); } - /** - * {@inheritDoc} - */ + @Override public Type getFilterParameterType(String filterParameterName) { errorIfClosed(); checkTransactionSynchStatus(); return loadQueryInfluencers.getFilterParameterType( filterParameterName ); } - /** - * {@inheritDoc} - */ + @Override public Map getEnabledFilters() { errorIfClosed(); checkTransactionSynchStatus(); @@ -2031,17 +2117,13 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // internal fetch profile support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - /** - * {@inheritDoc} - */ + @Override public String getFetchProfile() { checkTransactionSynchStatus(); return loadQueryInfluencers.getInternalFetchProfile(); } - /** - * {@inheritDoc} - */ + @Override public void setFetchProfile(String fetchProfile) { errorIfClosed(); checkTransactionSynchStatus(); @@ -2051,14 +2133,17 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc // fetch profile support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + @Override public boolean isFetchProfileEnabled(String name) throws UnknownProfileException { return loadQueryInfluencers.isFetchProfileEnabled( name ); } + @Override public void enableFetchProfile(String name) throws UnknownProfileException { loadQueryInfluencers.enableFetchProfile( name ); } + @Override public void disableFetchProfile(String name) throws UnknownProfileException { loadQueryInfluencers.disableFetchProfile( name ); } @@ -2152,9 +2237,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc oos.writeObject( loadQueryInfluencers ); } - /** - * {@inheritDoc} - */ + @Override public TypeHelper getTypeHelper() { return getSessionFactory().getTypeHelper(); } @@ -2324,6 +2407,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc } private class CoordinatingEntityNameResolver implements EntityNameResolver { + @Override public String resolveEntityName(Object entity) { String entityName = interceptor.getEntityName( entity ); if ( entityName != null ) { @@ -2353,36 +2437,45 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc LockOptions.copy(lo, lockOptions); } + @Override public LockMode getLockMode() { return lockOptions.getLockMode(); } + @Override public LockRequest setLockMode(LockMode lockMode) { lockOptions.setLockMode(lockMode); return this; } + @Override public int getTimeOut() { return lockOptions.getTimeOut(); } + @Override public LockRequest setTimeOut(int timeout) { lockOptions.setTimeOut(timeout); return this; } + @Override public boolean getScope() { return lockOptions.getScope(); } + @Override public LockRequest setScope(boolean scope) { lockOptions.setScope(scope); return this; } + @Override public void lock(String entityName, Object object) throws HibernateException { fireLock( entityName, object, lockOptions ); } + + @Override public void lock(Object object) throws HibernateException { fireLock( object, lockOptions ); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/TypeLocatorImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/TypeLocatorImpl.java index 1cd5c0a477..0ffe14c922 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/TypeLocatorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/TypeLocatorImpl.java @@ -45,16 +45,12 @@ public class TypeLocatorImpl implements TypeHelper, Serializable { this.typeResolver = typeResolver; } - /** - * {@inheritDoc} - */ + @Override public BasicType basic(String name) { return typeResolver.basic( name ); } - /** - * {@inheritDoc} - */ + @Override public BasicType basic(Class javaType) { BasicType type = typeResolver.basic( javaType.getName() ); if ( type == null ) { @@ -134,38 +130,28 @@ public class TypeLocatorImpl implements TypeHelper, Serializable { return null; } - /** - * {@inheritDoc} - */ + @Override public Type heuristicType(String name) { return typeResolver.heuristicType( name ); } - /** - * {@inheritDoc} - */ + @Override public Type entity(Class entityClass) { return entity( entityClass.getName() ); } - /** - * {@inheritDoc} - */ + @Override public Type entity(String entityName) { return typeResolver.getTypeFactory().manyToOne( entityName ); } - /** - * {@inheritDoc} - */ + @Override @SuppressWarnings({ "unchecked" }) public Type custom(Class userTypeClass) { return custom( userTypeClass, null ); } - /** - * {@inheritDoc} - */ + @Override @SuppressWarnings({ "unchecked" }) public Type custom(Class userTypeClass, Properties parameters) { if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) { @@ -176,9 +162,7 @@ public class TypeLocatorImpl implements TypeHelper, Serializable { } } - /** - * {@inheritDoc} - */ + @Override public Type any(Type metaType, Type identifierType) { return typeResolver.getTypeFactory().any( metaType, identifierType ); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ConcurrentReferenceHashMap.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ConcurrentReferenceHashMap.java index 7c334f2c94..9fb8a40ea8 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ConcurrentReferenceHashMap.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/ConcurrentReferenceHashMap.java @@ -319,10 +319,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap this.hash = hash; } + @Override public final int keyHash() { return hash; } + @Override public final Object keyRef() { return this; } @@ -339,10 +341,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap this.hash = hash; } + @Override public final int keyHash() { return hash; } + @Override public final Object keyRef() { return this; } @@ -358,10 +362,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap this.hash = hash; } + @Override public final int keyHash() { return hash; } + @Override public final Object keyRef() { return keyRef; } @@ -377,10 +383,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap this.hash = hash; } + @Override public final int keyHash() { return hash; } + @Override public final Object keyRef() { return keyRef; } @@ -1095,6 +1103,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @return true if this map contains no key-value mappings */ + @Override public boolean isEmpty() { final Segment[] segments = this.segments; /* @@ -1137,6 +1146,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @return the number of key-value mappings in this map */ + @Override public int size() { final Segment[] segments = this.segments; long sum = 0; @@ -1196,6 +1206,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public V get(Object key) { if ( key == null ) { return null; @@ -1215,6 +1226,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public boolean containsKey(Object key) { if ( key == null ) { return false; @@ -1234,6 +1246,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * @return true if this map maps one or more keys to the * specified value */ + @Override public boolean containsValue(Object value) { if ( value == null ) { return false; @@ -1326,6 +1339,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key or value is null */ + @Override public V put(K key, V value) { if ( key == null || value == null ) { return null; @@ -1342,6 +1356,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key or value is null */ + @Override public V putIfAbsent(K key, V value) { if ( key == null || value == null ) { return null; @@ -1357,6 +1372,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @param m mappings to be stored in this map */ + @Override public void putAll(Map m) { for ( Map.Entry e : m.entrySet() ) { put( e.getKey(), e.getValue() ); @@ -1374,6 +1390,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public V remove(Object key) { if ( key == null ) { return null; @@ -1387,6 +1404,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key is null */ + @Override public boolean remove(Object key, Object value) { if ( key == null || value == null ) { return false; @@ -1400,6 +1418,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if any of the arguments are null */ + @Override public boolean replace(K key, V oldValue, V newValue) { if ( key == null || oldValue == null || newValue == null ) { throw new NullPointerException(); @@ -1416,6 +1435,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * * @throws NullPointerException if the specified key or value is null */ + @Override public V replace(K key, V value) { if ( key == null || value == null ) { return null; @@ -1427,6 +1447,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap /** * Removes all of the mappings from this map. */ + @Override public void clear() { for ( int i = 0; i < segments.length; ++i ) { segments[i].clear(); @@ -1467,6 +1488,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * construction of the iterator, and may (but is not guaranteed to) * reflect any modifications subsequent to construction. */ + @Override public Set keySet() { Set ks = keySet; return ( ks != null ) ? ks : ( keySet = new KeySet() ); @@ -1488,6 +1510,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * construction of the iterator, and may (but is not guaranteed to) * reflect any modifications subsequent to construction. */ + @Override public Collection values() { Collection vs = values; return ( vs != null ) ? vs : ( values = new Values() ); @@ -1509,6 +1532,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * construction of the iterator, and may (but is not guaranteed to) * reflect any modifications subsequent to construction. */ + @Override public Set> entrySet() { Set> es = entrySet; return ( es != null ) ? es : ( entrySet = new EntrySet() ); @@ -1618,10 +1642,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap final class KeyIterator extends HashIterator implements Iterator, Enumeration { + @Override public K next() { return super.nextEntry().key(); } + @Override public K nextElement() { return super.nextEntry().key(); } @@ -1630,10 +1656,12 @@ public class ConcurrentReferenceHashMap extends AbstractMap final class ValueIterator extends HashIterator implements Iterator, Enumeration { + @Override public V next() { return super.nextEntry().value(); } + @Override public V nextElement() { return super.nextEntry().value(); } @@ -1659,20 +1687,24 @@ public class ConcurrentReferenceHashMap extends AbstractMap this.value = entry.getValue(); } + @Override public K getKey() { return key; } + @Override public V getValue() { return value; } + @Override public V setValue(V value) { V oldValue = this.value; this.value = value; return oldValue; } + @Override public boolean equals(Object o) { if ( !( o instanceof Map.Entry ) ) { return false; @@ -1682,11 +1714,13 @@ public class ConcurrentReferenceHashMap extends AbstractMap return eq( key, e.getKey() ) && eq( value, e.getValue() ); } + @Override public int hashCode() { return ( key == null ? 0 : key.hashCode() ) ^ ( value == null ? 0 : value.hashCode() ); } + @Override public String toString() { return key + "=" + value; } @@ -1717,6 +1751,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap * removed in which case the put will re-establish). We do not * and cannot guarantee more. */ + @Override public V setValue(V value) { if ( value == null ) { throw new NullPointerException(); @@ -1730,6 +1765,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap final class EntryIterator extends HashIterator implements Iterator> { + @Override public Map.Entry next() { HashEntry e = super.nextEntry(); return new WriteThroughEntry( e.key(), e.value() ); @@ -1737,58 +1773,71 @@ public class ConcurrentReferenceHashMap extends AbstractMap } final class KeySet extends AbstractSet { + @Override public Iterator iterator() { return new KeyIterator(); } + @Override public int size() { return ConcurrentReferenceHashMap.this.size(); } + @Override public boolean isEmpty() { return ConcurrentReferenceHashMap.this.isEmpty(); } + @Override public boolean contains(Object o) { return ConcurrentReferenceHashMap.this.containsKey( o ); } + @Override public boolean remove(Object o) { return ConcurrentReferenceHashMap.this.remove( o ) != null; } + @Override public void clear() { ConcurrentReferenceHashMap.this.clear(); } } final class Values extends AbstractCollection { + @Override public Iterator iterator() { return new ValueIterator(); } + @Override public int size() { return ConcurrentReferenceHashMap.this.size(); } + @Override public boolean isEmpty() { return ConcurrentReferenceHashMap.this.isEmpty(); } + @Override public boolean contains(Object o) { return ConcurrentReferenceHashMap.this.containsValue( o ); } + @Override public void clear() { ConcurrentReferenceHashMap.this.clear(); } } final class EntrySet extends AbstractSet> { + @Override public Iterator> iterator() { return new EntryIterator(); } + @Override public boolean contains(Object o) { if ( !( o instanceof Map.Entry ) ) { return false; @@ -1798,6 +1847,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap return v != null && v.equals( e.getValue() ); } + @Override public boolean remove(Object o) { if ( !( o instanceof Map.Entry ) ) { return false; @@ -1806,14 +1856,17 @@ public class ConcurrentReferenceHashMap extends AbstractMap return ConcurrentReferenceHashMap.this.remove( e.getKey(), e.getValue() ); } + @Override public int size() { return ConcurrentReferenceHashMap.this.size(); } + @Override public boolean isEmpty() { return ConcurrentReferenceHashMap.this.isEmpty(); } + @Override public void clear() { ConcurrentReferenceHashMap.this.clear(); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/OriginImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/OriginImpl.java index 8f58fcc095..5bd66025cd 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/OriginImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/OriginImpl.java @@ -39,16 +39,12 @@ public class OriginImpl implements Origin, Serializable { this.name = name; } - /** - * {@inheritDoc} - */ + @Override public String getType() { return type; } - /** - * {@inheritDoc} - */ + @Override public String getName() { return name; } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/XmlDocumentImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/XmlDocumentImpl.java index e936c92add..aac9763100 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/xml/XmlDocumentImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/xml/XmlDocumentImpl.java @@ -45,16 +45,12 @@ public class XmlDocumentImpl implements XmlDocument, Serializable { this.origin = origin; } - /** - * {@inheritDoc} - */ + @Override public Document getDocumentTree() { return documentTree; } - /** - * {@inheritDoc} - */ + @Override public Origin getOrigin() { return origin; } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java b/hibernate-core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java index ec9fdf17a5..d2b8789826 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/DefaultEntityAliases.java @@ -136,9 +136,7 @@ public class DefaultEntityAliases implements EntityAliases { } } - /** - * {@inheritDoc} - */ + @Override public String[][] getSuffixedPropertyAliases(Loadable persister) { final int size = persister.getPropertyNames().length; final String[][] suffixedPropertyAliases = new String[size][]; @@ -153,37 +151,27 @@ public class DefaultEntityAliases implements EntityAliases { return suffixedPropertyAliases; } - /** - * {@inheritDoc} - */ + @Override public String[] getSuffixedVersionAliases() { return suffixedVersionColumn; } - /** - * {@inheritDoc} - */ + @Override public String[][] getSuffixedPropertyAliases() { return suffixedPropertyColumns; } - /** - * {@inheritDoc} - */ + @Override public String getSuffixedDiscriminatorAlias() { return suffixedDiscriminatorColumn; } - /** - * {@inheritDoc} - */ + @Override public String[] getSuffixedKeyAliases() { return suffixedKeyColumns; } - /** - * {@inheritDoc} - */ + @Override public String getRowIdAlias() { return rowIdAlias; } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java index d8fe714890..0e1f6a0610 100755 --- a/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/criteria/CriteriaQueryTranslator.java @@ -245,7 +245,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery { final Type type = provider.getType( componentPath ); if ( type.isAssociationType() ) { // CollectionTypes are always also AssociationTypes - but there's not always an associated entity... - final AssociationType atype = ( AssociationType ) type; + final AssociationType atype = (AssociationType) type; final CollectionType ctype = type.isCollectionType() ? (CollectionType)type : null; final Type elementType = (ctype != null) ? ctype.getElementType( sessionFactory ) : null; // is the association a collection of components or value-types? (i.e a colloction of valued types?) @@ -256,16 +256,19 @@ public class CriteriaQueryTranslator implements CriteriaQuery { provider = new ScalarCollectionCriteriaInfoProvider( helper, ctype.getRole() ); } else { - provider = new EntityCriteriaInfoProvider(( Queryable ) sessionFactory.getEntityPersister( - atype.getAssociatedEntityName( sessionFactory ) - )); + provider = new EntityCriteriaInfoProvider( + (Queryable) sessionFactory.getEntityPersister( atype.getAssociatedEntityName( sessionFactory ) ) + ); } componentPath = ""; } else if ( type.isComponentType() ) { if (!tokens.hasMoreTokens()) { - throw new QueryException("Criteria objects cannot be created directly on components. Create a criteria on owning entity and use a dotted property to access component property: "+path); + throw new QueryException( + "Criteria objects cannot be created directly on components. Create a criteria on " + + "owning entity and use a dotted property to access component property: " + path + ); } else { componentPath += '.'; @@ -588,14 +591,15 @@ public class CriteriaQueryTranslator implements CriteriaQuery { public TypedValue getTypedValue(Criteria subcriteria, String propertyName, Object value) throws HibernateException { // Detect discriminator values... if ( value instanceof Class ) { - final Class entityClass = ( Class ) value; + final Class entityClass = (Class) value; final Queryable q = SessionFactoryHelper.findQueryableUsingImports( sessionFactory, entityClass.getName() ); if ( q != null ) { final Type type = q.getDiscriminatorType(); String stringValue = q.getDiscriminatorSQLValue(); - if (stringValue != null && stringValue.length() > 2 + if ( stringValue != null + && stringValue.length() > 2 && stringValue.startsWith( "'" ) - && stringValue.endsWith( "'" )) { + && stringValue.endsWith( "'" ) ) { // remove the single quotes stringValue = stringValue.substring( 1, stringValue.length() - 1 ); } @@ -616,7 +620,7 @@ public class CriteriaQueryTranslator implements CriteriaQuery { } private PropertyMapping getPropertyMapping(String entityName) throws MappingException { - final CriteriaInfoProvider info = nameCriteriaInfoMap.get(entityName); + final CriteriaInfoProvider info = nameCriteriaInfoMap.get( entityName ); if ( info == null ) { throw new HibernateException( "Unknown entity: " + entityName ); } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/build/spi/ReturnGraphTreePrinter.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/build/spi/ReturnGraphTreePrinter.java index 23042dcffb..f29414c85e 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/build/spi/ReturnGraphTreePrinter.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/build/spi/ReturnGraphTreePrinter.java @@ -198,21 +198,19 @@ public class ReturnGraphTreePrinter { CollectionReference collectionReference, int depth, PrintWriter printWriter) { - { - final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph(); - if ( indexGraph != null ) { - printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection index) " ); + final CollectionFetchableIndex indexGraph = collectionReference.getIndexGraph(); + if ( indexGraph != null ) { + printWriter.print( TreePrinterHelper.INSTANCE.generateNodePrefix( depth ) + "(collection index) " ); - if ( EntityReference.class.isInstance( indexGraph ) ) { - final EntityReference indexGraphAsEntityReference = (EntityReference) indexGraph; - printWriter.println( extractDetails( indexGraphAsEntityReference ) ); - writeEntityReferenceFetches( indexGraphAsEntityReference, depth+1, printWriter ); - } - else if ( CompositeFetch.class.isInstance( indexGraph ) ) { - final CompositeFetch indexGraphAsCompositeFetch = (CompositeFetch) indexGraph; - printWriter.println( extractDetails( indexGraphAsCompositeFetch ) ); - writeCompositeFetchFetches( indexGraphAsCompositeFetch, depth+1, printWriter ); - } + if ( EntityReference.class.isInstance( indexGraph ) ) { + final EntityReference indexGraphAsEntityReference = (EntityReference) indexGraph; + printWriter.println( extractDetails( indexGraphAsEntityReference ) ); + writeEntityReferenceFetches( indexGraphAsEntityReference, depth+1, printWriter ); + } + else if ( CompositeFetch.class.isInstance( indexGraph ) ) { + final CompositeFetch indexGraphAsCompositeFetch = (CompositeFetch) indexGraph; + printWriter.println( extractDetails( indexGraphAsCompositeFetch ) ); + writeCompositeFetchFetches( indexGraphAsCompositeFetch, depth+1, printWriter ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Backref.java b/hibernate-core/src/main/java/org/hibernate/mapping/Backref.java index c3d8cedd2e..e0359ed69c 100755 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Backref.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Backref.java @@ -22,6 +22,7 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.mapping; + import org.hibernate.property.BackrefPropertyAccessor; import org.hibernate.property.PropertyAccessor; @@ -32,16 +33,12 @@ public class Backref extends Property { private String collectionRole; private String entityName; - /** - * {@inheritDoc} - */ + @Override public boolean isBackRef() { return true; } - /** - * {@inheritDoc} - */ + @Override public boolean isSynthetic() { return true; } @@ -54,10 +51,12 @@ public class Backref extends Property { this.collectionRole = collectionRole; } + @Override public boolean isBasicPropertyAccessor() { return false; } + @Override public PropertyAccessor getPropertyAccessor(Class clazz) { return new BackrefPropertyAccessor(collectionRole, entityName); } @@ -65,6 +64,7 @@ public class Backref extends Property { public String getEntityName() { return entityName; } + public void setEntityName(String entityName) { this.entityName = entityName; } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java index 7a2bfe4ee6..1495f6be43 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Component.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Component.java @@ -52,7 +52,7 @@ import org.hibernate.type.TypeFactory; * @author Steve Ebersole */ public class Component extends SimpleValue implements MetaAttributable { - private ArrayList properties = new ArrayList(); + private ArrayList properties = new ArrayList(); private String componentClassName; private boolean embedded; private String parentProperty; @@ -63,7 +63,7 @@ public class Component extends SimpleValue implements MetaAttributable { private boolean isKey; private String roleName; - private java.util.Map tuplizerImpls; + private java.util.Map tuplizerImpls; public Component(Mappings mappings, PersistentClass owner) throws MappingException { super( mappings, owner.getTable() ); @@ -88,15 +88,21 @@ public class Component extends SimpleValue implements MetaAttributable { public int getPropertySpan() { return properties.size(); } + public Iterator getPropertyIterator() { return properties.iterator(); } + public void addProperty(Property p) { - properties.add(p); + properties.add( p ); } + + @Override public void addColumn(Column column) { throw new UnsupportedOperationException("Cant add a column to a component"); } + + @Override public int getColumnSpan() { int n=0; Iterator iter = getPropertyIterator(); @@ -106,6 +112,9 @@ public class Component extends SimpleValue implements MetaAttributable { } return n; } + + @Override + @SuppressWarnings("unchecked") public Iterator getColumnIterator() { Iterator[] iters = new Iterator[ getPropertySpan() ]; Iterator iter = getPropertyIterator(); @@ -113,11 +122,9 @@ public class Component extends SimpleValue implements MetaAttributable { while ( iter.hasNext() ) { iters[i++] = ( (Property) iter.next() ).getColumnIterator(); } - return new JoinedIterator(iters); + return new JoinedIterator( iters ); } - public void setTypeByReflection(String propertyClass, String propertyName) {} - public boolean isEmbedded() { return embedded; } @@ -167,6 +174,7 @@ public class Component extends SimpleValue implements MetaAttributable { this.dynamic = dynamic; } + @Override public Type getType() throws MappingException { // TODO : temporary initial step towards HHH-1907 final ComponentMetamodel metamodel = new ComponentMetamodel( this ); @@ -174,25 +182,32 @@ public class Component extends SimpleValue implements MetaAttributable { return isEmbedded() ? factory.embeddedComponent( metamodel ) : factory.component( metamodel ); } + @Override public void setTypeUsingReflection(String className, String propertyName) throws MappingException { } - + + @Override public java.util.Map getMetaAttributes() { return metaAttributes; } + + @Override public MetaAttribute getMetaAttribute(String attributeName) { return metaAttributes==null?null:(MetaAttribute) metaAttributes.get(attributeName); } + @Override public void setMetaAttributes(java.util.Map metas) { this.metaAttributes = metas; } - + + @Override public Object accept(ValueVisitor visitor) { return visitor.accept(this); } - + + @Override public boolean[] getColumnInsertability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); @@ -208,6 +223,7 @@ public class Component extends SimpleValue implements MetaAttributable { return result; } + @Override public boolean[] getColumnUpdateability() { boolean[] result = new boolean[ getColumnSpan() ]; Iterator iter = getPropertyIterator(); @@ -245,7 +261,7 @@ public class Component extends SimpleValue implements MetaAttributable { public void addTuplizer(EntityMode entityMode, String implClassName) { if ( tuplizerImpls == null ) { - tuplizerImpls = new HashMap(); + tuplizerImpls = new HashMap(); } tuplizerImpls.put( entityMode, implClassName ); } @@ -255,9 +271,10 @@ public class Component extends SimpleValue implements MetaAttributable { if ( tuplizerImpls == null ) { return null; } - return ( String ) tuplizerImpls.get( mode ); + return tuplizerImpls.get( mode ); } + @SuppressWarnings("UnusedDeclaration") public Map getTuplizerMap() { if ( tuplizerImpls == null ) { return null; @@ -284,12 +301,14 @@ public class Component extends SimpleValue implements MetaAttributable { this.roleName = roleName; } + @Override public String toString() { return getClass().getName() + '(' + properties.toString() + ')'; } private IdentifierGenerator builtIdentifierGenerator; + @Override public IdentifierGenerator createIdentifierGenerator( IdentifierGeneratorFactory identifierGeneratorFactory, Dialect dialect, @@ -396,6 +415,7 @@ public class Component extends SimpleValue implements MetaAttributable { this.entityName = entityName; } + @Override public Serializable locateGenerationContext(SessionImplementor session, Object incomingObject) { return session.getEntityPersister( entityName, incomingObject ).getIdentifier( incomingObject, session ); } @@ -415,14 +435,13 @@ public class Component extends SimpleValue implements MetaAttributable { this.injector = injector; } - /** - * {@inheritDoc} - */ + @Override public void execute(SessionImplementor session, Object incomingObject, Object injectionContext) { final Object generatedValue = subGenerator.generate( session, incomingObject ); injector.set( injectionContext, generatedValue, session.getFactory() ); } + @Override public void registerPersistentGenerators(Map generatorMap) { if ( PersistentIdentifierGenerator.class.isInstance( subGenerator ) ) { generatorMap.put( ( (PersistentIdentifierGenerator) subGenerator ).generatorKey(), subGenerator ); diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/FetchProfile.java b/hibernate-core/src/main/java/org/hibernate/mapping/FetchProfile.java index 028a17f56f..06448b1543 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/FetchProfile.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/FetchProfile.java @@ -88,9 +88,7 @@ public class FetchProfile { fetches.add( new Fetch( entity, association, style ) ); } - /** - * {@inheritDoc} - */ + @Override public boolean equals(Object o) { if ( this == o ) { return true; @@ -104,9 +102,7 @@ public class FetchProfile { return name.equals( that.name ); } - /** - * {@inheritDoc} - */ + @Override public int hashCode() { return name.hashCode(); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Formula.java b/hibernate-core/src/main/java/org/hibernate/mapping/Formula.java index 9bdbe798fe..6f43e825a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Formula.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Formula.java @@ -22,6 +22,7 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.mapping; + import java.io.Serializable; import org.hibernate.dialect.Dialect; @@ -33,7 +34,7 @@ import org.hibernate.sql.Template; * @author Gavin King */ public class Formula implements Selectable, Serializable { - private static int formulaUniqueInteger=0; + private static int formulaUniqueInteger; private String formula; private int uniqueInteger; diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/IndexBackref.java b/hibernate-core/src/main/java/org/hibernate/mapping/IndexBackref.java index 8a15df8f92..752bb93083 100755 --- a/hibernate-core/src/main/java/org/hibernate/mapping/IndexBackref.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/IndexBackref.java @@ -22,6 +22,7 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.mapping; + import org.hibernate.property.IndexPropertyAccessor; import org.hibernate.property.PropertyAccessor; @@ -31,14 +32,13 @@ import org.hibernate.property.PropertyAccessor; public class IndexBackref extends Property { private String collectionRole; private String entityName; - + + @Override public boolean isBackRef() { return true; } - /** - * {@inheritDoc} - */ + @Override public boolean isSynthetic() { return true; } @@ -51,10 +51,12 @@ public class IndexBackref extends Property { this.collectionRole = collectionRole; } + @Override public boolean isBasicPropertyAccessor() { return false; } + @Override public PropertyAccessor getPropertyAccessor(Class clazz) { return new IndexPropertyAccessor(collectionRole, entityName); } diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java index 7a3ca06838..00aa77fcbb 100644 --- a/hibernate-core/src/main/java/org/hibernate/mapping/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/mapping/Table.java @@ -248,7 +248,7 @@ public class Table implements RelationalModel, Serializable { return uniqueKeys; } - private int sizeOfUniqueKeyMapOnLastCleanse = 0; + private int sizeOfUniqueKeyMapOnLastCleanse; private void cleanseUniqueKeyMapIfNeeded() { if ( uniqueKeys.size() == sizeOfUniqueKeyMapOnLastCleanse ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/DerivedValue.java b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/DerivedValue.java index 13e8e39bdc..2f39332ac7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/relational/DerivedValue.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/relational/DerivedValue.java @@ -38,16 +38,11 @@ public class DerivedValue extends AbstractSimpleValue { this.expression = expression; } - /** - * {@inheritDoc} - */ + @Override public String toLoggableString() { return getTable().toLoggableString() + ".{derived-column}"; } - /** - * {@inheritDoc} - */ @Override public String getAlias(Dialect dialect) { return "formula" + Integer.toString( getPosition() ) + '_'; diff --git a/hibernate-core/src/main/java/org/hibernate/param/NamedParameterSpecification.java b/hibernate-core/src/main/java/org/hibernate/param/NamedParameterSpecification.java index 02efca32b2..3c347654c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/param/NamedParameterSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/param/NamedParameterSpecification.java @@ -60,6 +60,7 @@ public class NamedParameterSpecification extends AbstractExplicitParameterSpecif * * @return The number of sql bind positions "eaten" by this bind operation. */ + @Override public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position) throws SQLException { TypedValue typedValue = qp.getNamedParameters().get( name ); @@ -67,9 +68,7 @@ public class NamedParameterSpecification extends AbstractExplicitParameterSpecif return typedValue.getType().getColumnSpan( session.getFactory() ); } - /** - * {@inheritDoc} - */ + @Override public String renderDisplayInfo() { return "name=" + name + ", expectedType=" + getExpectedType(); } diff --git a/hibernate-core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java b/hibernate-core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java index 24c047b96d..60a6d6042d 100644 --- a/hibernate-core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/param/PositionalParameterSpecification.java @@ -60,6 +60,7 @@ public class PositionalParameterSpecification extends AbstractExplicitParameterS * * @return The number of sql bind positions "eaten" by this bind operation. */ + @Override public int bind(PreparedStatement statement, QueryParameters qp, SessionImplementor session, int position) throws SQLException { Type type = qp.getPositionalParameterTypes()[hqlPosition]; Object value = qp.getPositionalParameterValues()[hqlPosition]; @@ -68,9 +69,7 @@ public class PositionalParameterSpecification extends AbstractExplicitParameterS return type.getColumnSpan( session.getFactory() ); } - /** - * {@inheritDoc} - */ + @Override public String renderDisplayInfo() { return "ordinal=" + hqlPosition + ", expectedType=" + getExpectedType(); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index 3af96c7b4f..70e0647ce6 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -671,6 +671,7 @@ public abstract class AbstractCollectionPersister } } + @Override public void postInstantiate() throws MappingException { initializer = queryLoaderName == null ? createCollectionInitializer( LoadQueryInfluencers.NONE ) : @@ -687,6 +688,7 @@ public abstract class AbstractCollectionPersister } } + @Override public void initialize(Serializable key, SessionImplementor session) throws HibernateException { getAppropriateInitializer( key, session ).initialize( key, session ); } @@ -744,14 +746,17 @@ public abstract class AbstractCollectionPersister protected abstract CollectionInitializer createCollectionInitializer(LoadQueryInfluencers loadQueryInfluencers) throws MappingException; + @Override public CollectionRegionAccessStrategy getCacheAccessStrategy() { return cacheAccessStrategy; } + @Override public boolean hasCache() { return cacheAccessStrategy != null; } + @Override public CollectionType getCollectionType() { return collectionType; } @@ -760,30 +765,36 @@ public abstract class AbstractCollectionPersister return StringHelper.replace( sqlWhereStringTemplate, Template.TEMPLATE, alias ); } + @Override public String getSQLOrderByString(String alias) { return hasOrdering() ? orderByTranslation.injectAliases( new StandardOrderByAliasResolver( alias ) ) : ""; } + @Override public String getManyToManyOrderByString(String alias) { return hasManyToManyOrdering() ? manyToManyOrderByTranslation.injectAliases( new StandardOrderByAliasResolver( alias ) ) : ""; } + @Override public FetchMode getFetchMode() { return fetchMode; } + @Override public boolean hasOrdering() { return hasOrder; } + @Override public boolean hasManyToManyOrdering() { return isManyToMany() && hasManyToManyOrder; } + @Override public boolean hasWhere() { return hasWhere; } @@ -804,30 +815,36 @@ public abstract class AbstractCollectionPersister return sqlDeleteRowString; } + @Override public Type getKeyType() { return keyType; } + @Override public Type getIndexType() { return indexType; } + @Override public Type getElementType() { return elementType; } /** - * Return the element class of an array, or null otherwise + * Return the element class of an array, or null otherwise. needed by arrays */ - public Class getElementClass() { // needed by arrays + @Override + public Class getElementClass() { return elementClass; } + @Override public Object readElement(ResultSet rs, Object owner, String[] aliases, SessionImplementor session) throws HibernateException, SQLException { return getElementType().nullSafeGet( rs, aliases, session, owner ); } + @Override public Object readIndex(ResultSet rs, String[] aliases, SessionImplementor session) throws HibernateException, SQLException { Object index = getIndexType().nullSafeGet( rs, aliases, session, null ); @@ -845,6 +862,7 @@ public abstract class AbstractCollectionPersister return index; } + @Override public Object readIdentifier(ResultSet rs, String alias, SessionImplementor session) throws HibernateException, SQLException { Object id = getIdentifierType().nullSafeGet( rs, alias, session, null ); @@ -854,6 +872,7 @@ public abstract class AbstractCollectionPersister return id; } + @Override public Object readKey(ResultSet rs, String[] aliases, SessionImplementor session) throws HibernateException, SQLException { return getKeyType().nullSafeGet( rs, aliases, session, null ); @@ -933,22 +952,27 @@ public abstract class AbstractCollectionPersister return i + 1; } + @Override public boolean isPrimitiveArray() { return isPrimitiveArray; } + @Override public boolean isArray() { return isArray; } + @Override public String[] getKeyColumnAliases(String suffix) { return new Alias( suffix ).toAliasStrings( keyColumnAliases ); } + @Override public String[] getElementColumnAliases(String suffix) { return new Alias( suffix ).toAliasStrings( elementColumnAliases ); } + @Override public String[] getIndexColumnAliases(String suffix) { if ( hasIndex ) { return new Alias( suffix ).toAliasStrings( indexColumnAliases ); @@ -958,6 +982,7 @@ public abstract class AbstractCollectionPersister } } + @Override public String getIdentifierColumnAlias(String suffix) { if ( hasIdentifier ) { return new Alias( suffix ).toAliasString( identifierColumnAlias ); @@ -967,6 +992,7 @@ public abstract class AbstractCollectionPersister } } + @Override public String getIdentifierColumnName() { if ( hasIdentifier ) { return identifierColumnName; @@ -979,6 +1005,7 @@ public abstract class AbstractCollectionPersister /** * Generate a list of collection index, key and element columns */ + @Override public String selectFragment(String alias, String columnSuffix) { SelectFragment frag = generateSelectFragment( alias, columnSuffix ); appendElementColumns( frag, alias ); @@ -1073,19 +1100,22 @@ public abstract class AbstractCollectionPersister } } + @Override public String[] getIndexColumnNames() { return indexColumnNames; } + @Override public String[] getIndexFormulas() { return indexFormulas; } + @Override public String[] getIndexColumnNames(String alias) { return qualify( alias, indexColumnNames, indexFormulaTemplates ); - } + @Override public String[] getElementColumnNames(String alias) { return qualify( alias, elementColumnNames, elementFormulaTemplates ); } @@ -1104,32 +1134,39 @@ public abstract class AbstractCollectionPersister return result; } + @Override public String[] getElementColumnNames() { return elementColumnNames; // TODO: something with formulas... } + @Override public String[] getKeyColumnNames() { return keyColumnNames; } + @Override public boolean hasIndex() { return hasIndex; } + @Override public boolean isLazy() { return isLazy; } + @Override public boolean isInverse() { return isInverse; } + @Override public String getTableName() { return qualifiedTableName; } private BasicBatchKey removeBatchKey; + @Override public void remove(Serializable id, SessionImplementor session) throws HibernateException { if ( !isInverse && isRowDeleteEnabled() ) { @@ -1209,6 +1246,7 @@ public abstract class AbstractCollectionPersister protected BasicBatchKey recreateBatchKey; + @Override public void recreate(PersistentCollection collection, Serializable id, SessionImplementor session) throws HibernateException { @@ -1322,6 +1360,7 @@ public abstract class AbstractCollectionPersister private BasicBatchKey deleteBatchKey; + @Override public void deleteRows(PersistentCollection collection, Serializable id, SessionImplementor session) throws HibernateException { @@ -1430,6 +1469,7 @@ public abstract class AbstractCollectionPersister private BasicBatchKey insertBatchKey; + @Override public void insertRows(PersistentCollection collection, Serializable id, SessionImplementor session) throws HibernateException { @@ -1524,6 +1564,7 @@ public abstract class AbstractCollectionPersister } } + @Override public String getRole() { return role; } @@ -1532,22 +1573,27 @@ public abstract class AbstractCollectionPersister return entityName; } + @Override public EntityPersister getOwnerEntityPersister() { return ownerPersister; } + @Override public IdentifierGenerator getIdentifierGenerator() { return identifierGenerator; } + @Override public Type getIdentifierType() { return identifierType; } + @Override public boolean hasOrphanDelete() { return hasOrphanDelete; } + @Override public Type toType(String propertyName) throws QueryException { if ( "index".equals( propertyName ) ) { return indexType; @@ -1555,8 +1601,10 @@ public abstract class AbstractCollectionPersister return elementPropertyMapping.toType( propertyName ); } + @Override public abstract boolean isManyToMany(); + @Override public String getManyToManyFilterFragment(String alias, Map enabledFilters) { StringBuilder buffer = new StringBuilder(); manyToManyFilterHelper.render( buffer, elementPersister.getFilterAliasGenerator(alias), enabledFilters ); @@ -1569,9 +1617,7 @@ public abstract class AbstractCollectionPersister return buffer.toString(); } - /** - * {@inheritDoc} - */ + @Override public String[] toColumns(String alias, String propertyName) throws QueryException { if ( "index".equals( propertyName ) ) { return qualify( alias, indexColumnNames, indexFormulaTemplates ); @@ -1581,9 +1627,7 @@ public abstract class AbstractCollectionPersister private String[] indexFragments; - /** - * {@inheritDoc} - */ + @Override public String[] toColumns(String propertyName) throws QueryException { if ( "index".equals( propertyName ) ) { if ( indexFragments == null ) { @@ -1601,14 +1645,17 @@ public abstract class AbstractCollectionPersister return elementPropertyMapping.toColumns( propertyName ); } + @Override public Type getType() { return elementPropertyMapping.getType(); // ==elementType ?? } + @Override public String getName() { return getRole(); } + @Override public EntityPersister getElementPersister() { if ( elementPersister == null ) { throw new AssertionFailure( "not an association" ); @@ -1616,10 +1663,12 @@ public abstract class AbstractCollectionPersister return elementPersister; } + @Override public boolean isCollection() { return true; } + @Override public Serializable[] getCollectionSpaces() { return spaces; } @@ -1632,6 +1681,7 @@ public abstract class AbstractCollectionPersister protected abstract String generateInsertRowString(); + @Override public void updateRows(PersistentCollection collection, Serializable id, SessionImplementor session) throws HibernateException { @@ -1649,6 +1699,7 @@ public abstract class AbstractCollectionPersister protected abstract int doUpdateRows(Serializable key, PersistentCollection collection, SessionImplementor session) throws HibernateException; + @Override public void processQueuedOps(PersistentCollection collection, Serializable key, SessionImplementor session) throws HibernateException { if ( collection.hasQueuedOperations() ) { @@ -1659,10 +1710,12 @@ public abstract class AbstractCollectionPersister protected abstract void doProcessQueuedOps(PersistentCollection collection, Serializable key, SessionImplementor session) throws HibernateException; + @Override public CollectionMetadata getCollectionMetadata() { return this; } + @Override public SessionFactoryImplementor getFactory() { return factory; } @@ -1675,6 +1728,7 @@ public abstract class AbstractCollectionPersister return hasWhere() ? " and " + getSQLWhereString( alias ) : ""; } + @Override public String filterFragment(String alias, Map enabledFilters) throws MappingException { StringBuilder sessionFilterFragment = new StringBuilder(); filterHelper.render( sessionFilterFragment, getFilterAliasGenerator(alias), enabledFilters ); @@ -1735,22 +1789,27 @@ public abstract class AbstractCollectionPersister return deleteAllCheckStyle; } + @Override public String toString() { return StringHelper.unqualify( getClass().getName() ) + '(' + role + ')'; } + @Override public boolean isVersioned() { return isVersioned && getOwnerEntityPersister().isVersioned(); } + @Override public String getNodeName() { return nodeName; } + @Override public String getElementNodeName() { return elementNodeName; } + @Override public String getIndexNodeName() { return indexNodeName; } @@ -1765,10 +1824,12 @@ public abstract class AbstractCollectionPersister return sqlExceptionHelper; } + @Override public CacheEntryStructure getCacheEntryStructure() { return cacheEntryStructure; } + @Override public boolean isAffectedByEnabledFilters(SessionImplementor session) { return filterHelper.isAffectedBy( session.getEnabledFilters() ) || ( isManyToMany() && manyToManyFilterHelper.isAffectedBy( session.getEnabledFilters() ) ); @@ -1778,10 +1839,12 @@ public abstract class AbstractCollectionPersister return subselectLoadable; } + @Override public boolean isMutable() { return isMutable; } + @Override public String[] getCollectionPropertyColumnAliases(String propertyName, String suffix) { String[] rawAliases = (String[]) collectionPropertyColumnAliases.get( propertyName ); @@ -1830,6 +1893,7 @@ public abstract class AbstractCollectionPersister } + @Override public int getSize(Serializable key, SessionImplementor session) { try { PreparedStatement st = session.getTransactionCoordinator() @@ -1860,10 +1924,12 @@ public abstract class AbstractCollectionPersister } } + @Override public boolean indexExists(Serializable key, Object index, SessionImplementor session) { return exists( key, incrementIndexByBase( index ), getIndexType(), sqlDetectRowByIndexString, session ); } + @Override public boolean elementExists(Serializable key, Object element, SessionImplementor session) { return exists( key, element, getElementType(), sqlDetectRowByElementString, session ); } @@ -1902,6 +1968,7 @@ public abstract class AbstractCollectionPersister } } + @Override public Object getElementByIndex(Serializable key, Object index, SessionImplementor session, Object owner) { try { PreparedStatement st = session.getTransactionCoordinator() @@ -1938,6 +2005,7 @@ public abstract class AbstractCollectionPersister } } + @Override public boolean isExtraLazy() { return isExtraLazy; } @@ -1956,10 +2024,12 @@ public abstract class AbstractCollectionPersister return initializer; } + @Override public int getBatchSize() { return batchSize; } + @Override public String getMappedByProperty() { return mappedByProperty; } diff --git a/hibernate-core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java index d4872b15b8..c663adac06 100755 --- a/hibernate-core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/BackrefPropertyAccessor.java @@ -55,6 +55,7 @@ public class BackrefPropertyAccessor implements PropertyAccessor { * we don't know the value of the back reference */ public static final Serializable UNKNOWN = new Serializable() { + @Override public String toString() { return ""; } @@ -78,16 +79,12 @@ public class BackrefPropertyAccessor implements PropertyAccessor { this.getter = new BackrefGetter(); } - /** - * {@inheritDoc} - */ + @Override public Setter getSetter(Class theClass, String propertyName) { return setter; } - /** - * {@inheritDoc} - */ + @Override public Getter getGetter(Class theClass, String propertyName) { return getter; } @@ -97,24 +94,17 @@ public class BackrefPropertyAccessor implements PropertyAccessor { * Internal implementation of a property setter specific to these back-ref properties. */ public static final class BackrefSetter implements Setter { - - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public void set(Object target, Object value, SessionFactoryImplementor factory) { // this page intentionally left blank :) } @@ -126,10 +116,7 @@ public class BackrefPropertyAccessor implements PropertyAccessor { * Internal implementation of a property getter specific to these back-ref properties. */ public class BackrefGetter implements Getter { - - /** - * {@inheritDoc} - */ + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { if ( session == null ) { return UNKNOWN; @@ -139,37 +126,27 @@ public class BackrefPropertyAccessor implements PropertyAccessor { } } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return null; } - /** - * {@inheritDoc} - */ + @Override public Object get(Object target) { return UNKNOWN; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return Object.class; } diff --git a/hibernate-core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java index 7e8286541c..ea835a736f 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/BasicPropertyAccessor.java @@ -35,6 +35,7 @@ import org.hibernate.PropertyNotFoundException; import org.hibernate.PropertySetterAccessException; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; @@ -47,8 +48,7 @@ import org.jboss.logging.Logger; * @author Gavin King */ public class BasicPropertyAccessor implements PropertyAccessor { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, BasicPropertyAccessor.class.getName()); + private static final CoreMessageLogger LOG = CoreLogging.messageLogger( BasicPropertyAccessor.class ); public static final class BasicSetter implements Setter { private Class clazz; @@ -61,6 +61,7 @@ public class BasicPropertyAccessor implements PropertyAccessor { this.propertyName=propertyName; } + @Override public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try { @@ -131,10 +132,12 @@ public class BasicPropertyAccessor implements PropertyAccessor { } } + @Override public Method getMethod() { return method; } + @Override public String getMethodName() { return method.getName(); } @@ -160,9 +163,7 @@ public class BasicPropertyAccessor implements PropertyAccessor { this.propertyName=propertyName; } - /** - * {@inheritDoc} - */ + @Override public Object get(Object target) throws HibernateException { try { return method.invoke( target, (Object[]) null ); @@ -198,37 +199,27 @@ public class BasicPropertyAccessor implements PropertyAccessor { } } - /** - * {@inheritDoc} - */ + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { return get( target ); } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return method.getReturnType(); } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return method; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return method; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return method.getName(); } @@ -244,13 +235,12 @@ public class BasicPropertyAccessor implements PropertyAccessor { } - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + @Override + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return createSetter(theClass, propertyName); } - private static Setter createSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + private static Setter createSetter(Class theClass, String propertyName) throws PropertyNotFoundException { BasicSetter result = getSetterOrNull(theClass, propertyName); if (result==null) { throw new PropertyNotFoundException( @@ -287,7 +277,6 @@ public class BasicPropertyAccessor implements PropertyAccessor { } private static Method setterMethod(Class theClass, String propertyName) { - BasicGetter getter = getGetterOrNull(theClass, propertyName); Class returnType = (getter==null) ? null : getter.getReturnType(); @@ -310,6 +299,7 @@ public class BasicPropertyAccessor implements PropertyAccessor { return potentialSetter; } + @Override public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return createGetter(theClass, propertyName); } diff --git a/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java index 67b5670f80..1858960b27 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/DirectPropertyAccessor.java @@ -51,9 +51,7 @@ public class DirectPropertyAccessor implements PropertyAccessor { this.name = name; } - /** - * {@inheritDoc} - */ + @Override public Object get(Object target) throws HibernateException { try { return field.get(target); @@ -63,37 +61,27 @@ public class DirectPropertyAccessor implements PropertyAccessor { } } - /** - * {@inheritDoc} - */ + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { return get( target ); } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return field; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return field.getType(); } @@ -101,7 +89,8 @@ public class DirectPropertyAccessor implements PropertyAccessor { Object readResolve() { return new DirectGetter( getField(clazz, name), clazz, name ); } - + + @Override public String toString() { return "DirectGetter(" + clazz.getName() + '.' + name + ')'; } @@ -117,23 +106,17 @@ public class DirectPropertyAccessor implements PropertyAccessor { this.name = name; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { try { field.set(target, value); @@ -153,6 +136,7 @@ public class DirectPropertyAccessor implements PropertyAccessor { } } + @Override public String toString() { return "DirectSetter(" + clazz.getName() + '.' + name + ')'; } @@ -191,14 +175,14 @@ public class DirectPropertyAccessor implements PropertyAccessor { if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; } - - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + + @Override + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new DirectGetter( getField(theClass, propertyName), theClass, propertyName ); } - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + @Override + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new DirectSetter( getField(theClass, propertyName), theClass, propertyName ); } diff --git a/hibernate-core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java index 96127f0c52..4cd4f9cce4 100755 --- a/hibernate-core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/EmbeddedPropertyAccessor.java @@ -35,56 +35,45 @@ import org.hibernate.engine.spi.SessionImplementor; * @author Gavin King */ public class EmbeddedPropertyAccessor implements PropertyAccessor { - + public static final class EmbeddedGetter implements Getter { private final Class clazz; EmbeddedGetter(Class clazz) { this.clazz = clazz; } - - /** - * {@inheritDoc} - */ + + @Override public Object get(Object target) throws HibernateException { return target; } - - /** - * {@inheritDoc} - */ + + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { return get( target ); } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return null; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return clazz; } - + + @Override public String toString() { return "EmbeddedGetter(" + clazz.getName() + ')'; } @@ -96,42 +85,34 @@ public class EmbeddedPropertyAccessor implements PropertyAccessor { EmbeddedSetter(Class clazz) { this.clazz = clazz; } - - /** - * {@inheritDoc} - */ + + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public void set(Object target, Object value, SessionFactoryImplementor factory) { } - /** - * {@inheritDoc} - */ + @Override public String toString() { return "EmbeddedSetter(" + clazz.getName() + ')'; } } - public Getter getGetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + @Override + public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new EmbeddedGetter(theClass); } - public Setter getSetter(Class theClass, String propertyName) - throws PropertyNotFoundException { + @Override + public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new EmbeddedSetter(theClass); } diff --git a/hibernate-core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java index 8a3f23bbce..a80b2ede45 100755 --- a/hibernate-core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/IndexPropertyAccessor.java @@ -50,10 +50,12 @@ public class IndexPropertyAccessor implements PropertyAccessor { this.entityName = entityName; } + @Override public Setter getSetter(Class theClass, String propertyName) { return new IndexSetter(); } + @Override public Getter getGetter(Class theClass, String propertyName) { return new IndexGetter(); } @@ -63,27 +65,20 @@ public class IndexPropertyAccessor implements PropertyAccessor { * The Setter implementation for index backrefs. */ public static final class IndexSetter implements Setter { - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public void set(Object target, Object value, SessionFactoryImplementor factory) { // do nothing... } - } @@ -91,47 +86,37 @@ public class IndexPropertyAccessor implements PropertyAccessor { * The Getter implementation for index backrefs. */ public class IndexGetter implements Getter { + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) throws HibernateException { - if (session==null) { + if ( session == null ) { return BackrefPropertyAccessor.UNKNOWN; } else { - return session.getPersistenceContext() - .getIndexInOwner(entityName, propertyName, target, mergeMap); + return session.getPersistenceContext().getIndexInOwner( entityName, propertyName, target, mergeMap ); } } - /** - * {@inheritDoc} - */ + @Override public Object get(Object target) { return BackrefPropertyAccessor.UNKNOWN; } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return null; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return Object.class; } diff --git a/hibernate-core/src/main/java/org/hibernate/property/MapAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/MapAccessor.java index ef6e097dd1..f239999f7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/property/MapAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/MapAccessor.java @@ -35,17 +35,13 @@ import org.hibernate.engine.spi.SessionImplementor; * @author Gavin King */ public class MapAccessor implements PropertyAccessor { - /** - * {@inheritDoc} - */ + @Override public Getter getGetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new MapGetter(propertyName); } - /** - * {@inheritDoc} - */ + @Override public Setter getSetter(Class theClass, String propertyName) throws PropertyNotFoundException { return new MapSetter(propertyName); @@ -58,26 +54,21 @@ public class MapAccessor implements PropertyAccessor { this.name = name; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override + @SuppressWarnings("unchecked") public void set(Object target, Object value, SessionFactoryImplementor factory) throws HibernateException { - ( (Map) target ).put(name, value); + ( (Map) target ).put( name, value ); } } @@ -89,44 +80,32 @@ public class MapAccessor implements PropertyAccessor { this.name = name; } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return null; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Object get(Object target) throws HibernateException { return ( (Map) target ).get(name); } - /** - * {@inheritDoc} - */ + @Override public Object getForInsert(Object target, Map mergeMap, SessionImplementor session) { return get( target ); } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return Object.class; } diff --git a/hibernate-core/src/main/java/org/hibernate/property/NoopAccessor.java b/hibernate-core/src/main/java/org/hibernate/property/NoopAccessor.java index e2eee4395b..3dfa3e45c8 100755 --- a/hibernate-core/src/main/java/org/hibernate/property/NoopAccessor.java +++ b/hibernate-core/src/main/java/org/hibernate/property/NoopAccessor.java @@ -37,16 +37,12 @@ import org.hibernate.engine.spi.SessionImplementor; * @author Michael Bartmann */ public class NoopAccessor implements PropertyAccessor { - /** - * {@inheritDoc} - */ + @Override public Getter getGetter(Class arg0, String arg1) throws PropertyNotFoundException { return new NoopGetter(); } - /** - * {@inheritDoc} - */ + @Override public Setter getSetter(Class arg0, String arg1) throws PropertyNotFoundException { return new NoopSetter(); } @@ -60,42 +56,33 @@ public class NoopAccessor implements PropertyAccessor { *

* Here we always return null */ + @Override public Object get(Object target) throws HibernateException { return null; } - /** - * {@inheritDoc} - */ + @Override public Object getForInsert(Object target, Map map, SessionImplementor arg1) throws HibernateException { return null; } - /** - * {@inheritDoc} - */ + @Override public Class getReturnType() { return Object.class; } - /** - * {@inheritDoc} - */ + @Override public Member getMember() { return null; } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } @@ -105,23 +92,17 @@ public class NoopAccessor implements PropertyAccessor { * A Setter which will just do nothing. */ private static class NoopSetter implements Setter { - /** - * {@inheritDoc} - */ + @Override public void set(Object target, Object value, SessionFactoryImplementor arg2) { // nothing to do } - /** - * {@inheritDoc} - */ + @Override public String getMethodName() { return null; } - /** - * {@inheritDoc} - */ + @Override public Method getMethod() { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java b/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java index 29aae78704..9146259162 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanConstructorResultTransformer.java @@ -49,6 +49,7 @@ public class AliasToBeanConstructorResultTransformer implements ResultTransforme /** * Wrap the incoming tuples in a call to our configured constructor. */ + @Override public Object transformTuple(Object[] tuple, String[] aliases) { try { return constructor.newInstance( tuple ); @@ -61,9 +62,7 @@ public class AliasToBeanConstructorResultTransformer implements ResultTransforme } } - /** - * {@inheritDoc} - */ + @Override public List transformList(List collection) { return collection; } @@ -73,6 +72,7 @@ public class AliasToBeanConstructorResultTransformer implements ResultTransforme * * @return Our defined ctor hashCode */ + @Override public int hashCode() { return constructor.hashCode(); } @@ -84,6 +84,7 @@ public class AliasToBeanConstructorResultTransformer implements ResultTransforme * @param other The other instance to check for equality. * @return True if both have the same defined constuctor; false otherwise. */ + @Override public boolean equals(Object other) { return other instanceof AliasToBeanConstructorResultTransformer && constructor.equals( ( ( AliasToBeanConstructorResultTransformer ) other ).constructor ); diff --git a/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java b/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java index ff36ac709c..a0ca473307 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/AliasToBeanResultTransformer.java @@ -70,13 +70,12 @@ public class AliasToBeanResultTransformer extends AliasedTupleSubsetResultTransf this.resultClass = resultClass; } - /** - * {@inheritDoc} - */ + @Override public boolean isTransformedValueATupleElement(String[] aliases, int tupleLength) { return false; - } + } + @Override public Object transformTuple(Object[] tuple, String[] aliases) { Object result; @@ -133,6 +132,7 @@ public class AliasToBeanResultTransformer extends AliasedTupleSubsetResultTransf } } + @Override public boolean equals(Object o) { if ( this == o ) { return true; @@ -153,6 +153,7 @@ public class AliasToBeanResultTransformer extends AliasedTupleSubsetResultTransf return true; } + @Override public int hashCode() { int result = resultClass.hashCode(); result = 31 * result + ( aliases != null ? Arrays.hashCode( aliases ) : 0 ); diff --git a/hibernate-core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java b/hibernate-core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java index 419952bda1..c0712536f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/transform/AliasToEntityMapResultTransformer.java @@ -46,9 +46,7 @@ public class AliasToEntityMapResultTransformer extends AliasedTupleSubsetResultT private AliasToEntityMapResultTransformer() { } - /** - * {@inheritDoc} - */ + @Override public Object transformTuple(Object[] tuple, String[] aliases) { Map result = new HashMap(tuple.length); for ( int i=0; i 0 @@ -702,6 +704,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { throw new MappingException( "component property not found: " + subPropertyName ); } + @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { boolean setAll = !entityMetamodel.hasLazyProperties(); @@ -712,20 +715,24 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { } } + @Override public void setPropertyValue(Object entity, int i, Object value) throws HibernateException { setters[i].set( entity, value, getFactory() ); } + @Override public void setPropertyValue(Object entity, String propertyName, Object value) throws HibernateException { setters[ entityMetamodel.getPropertyIndex( propertyName ) ].set( entity, value, getFactory() ); } + @Override public final Object instantiate(Serializable id) throws HibernateException { // 99% of the time the session is not needed. Its only needed for certain brain-dead // interpretations of JPA 2 "derived identity" support return instantiate( id, null ); } + @Override public final Object instantiate(Serializable id, SessionImplementor session) { Object result = getInstantiator().instantiate( id ); if ( id != null ) { @@ -734,30 +741,37 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { return result; } + @Override public final Object instantiate() throws HibernateException { return instantiate( null, null ); } + @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) {} + @Override public boolean hasUninitializedLazyProperties(Object entity) { // the default is to simply not lazy fetch properties for now... return false; } + @Override public final boolean isInstance(Object object) { return getInstantiator().isInstance( object ); } + @Override public boolean hasProxy() { return entityMetamodel.isLazy(); } + @Override public final Object createProxy(Serializable id, SessionImplementor session) throws HibernateException { return getProxyFactory().getProxy( id, session ); } + @Override public boolean isLifecycleImplementor() { return false; } @@ -783,10 +797,12 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { return getClass().getName() + '(' + getEntityMetamodel().getName() + ')'; } + @Override public Getter getIdentifierGetter() { return idGetter; } + @Override public Getter getVersionGetter() { if ( getEntityMetamodel().isVersioned() ) { return getGetter( getEntityMetamodel().getVersionPropertyIndex() ); @@ -794,6 +810,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { return null; } + @Override public Getter getGetter(int i) { return getters[i]; } diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java index 58fc652008..7e376d62b5 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/DynamicMapEntityTuplizer.java @@ -29,6 +29,7 @@ import org.hibernate.EntityMode; import org.hibernate.EntityNameResolver; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; @@ -43,8 +44,6 @@ import org.hibernate.proxy.map.MapProxyFactory; import org.hibernate.tuple.DynamicMapInstantiator; import org.hibernate.tuple.Instantiator; -import org.jboss.logging.Logger; - /** * An {@link EntityTuplizer} specific to the dynamic-map entity mode. * @@ -52,9 +51,7 @@ import org.jboss.logging.Logger; * @author Gavin King */ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, - DynamicMapEntityTuplizer.class.getName()); + private static final CoreMessageLogger LOG = CoreLogging.messageLogger( DynamicMapEntityTuplizer.class ); DynamicMapEntityTuplizer(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) { super(entityMetamodel, mappedEntity); @@ -64,9 +61,7 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { super(entityMetamodel, mappedEntity); } - /** - * {@inheritDoc} - */ + @Override public EntityMode getEntityMode() { return EntityMode.MAP; } @@ -80,33 +75,21 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) { return buildPropertyAccessor(mappedProperty).getGetter( null, mappedProperty.getName() ); } - /** - * {@inheritDoc} - */ @Override protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) { return buildPropertyAccessor(mappedProperty).getSetter( null, mappedProperty.getName() ); } - /** - * {@inheritDoc} - */ @Override protected Instantiator buildInstantiator(PersistentClass mappingInfo) { return new DynamicMapInstantiator( mappingInfo ); } - /** - * {@inheritDoc} - */ @Override protected ProxyFactory buildProxyFactory(PersistentClass mappingInfo, Getter idGetter, Setter idSetter) { @@ -139,33 +122,21 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { //} } - /** - * {@inheritDoc} - */ @Override protected Getter buildPropertyGetter(AttributeBinding mappedProperty) { return buildPropertyAccessor( mappedProperty ).getGetter( null, mappedProperty.getAttribute().getName() ); } - /** - * {@inheritDoc} - */ @Override protected Setter buildPropertySetter(AttributeBinding mappedProperty) { return buildPropertyAccessor( mappedProperty ).getSetter( null, mappedProperty.getAttribute().getName() ); } - /** - * {@inheritDoc} - */ @Override protected Instantiator buildInstantiator(EntityBinding mappingInfo) { return new DynamicMapInstantiator( mappingInfo ); } - /** - * {@inheritDoc} - */ @Override protected ProxyFactory buildProxyFactory(EntityBinding mappingInfo, Getter idGetter, Setter idSetter) { @@ -188,37 +159,27 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { return pf; } - /** - * {@inheritDoc} - */ + @Override public Class getMappedClass() { return Map.class; } - /** - * {@inheritDoc} - */ + @Override public Class getConcreteProxyClass() { return Map.class; } - /** - * {@inheritDoc} - */ + @Override public boolean isInstrumented() { return false; } - /** - * {@inheritDoc} - */ + @Override public EntityNameResolver[] getEntityNameResolvers() { return new EntityNameResolver[] { BasicEntityNameResolver.INSTANCE }; } - /** - * {@inheritDoc} - */ + @Override public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { return extractEmbeddedEntityName( ( Map ) entityInstance ); } @@ -230,9 +191,7 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { public static class BasicEntityNameResolver implements EntityNameResolver { public static final BasicEntityNameResolver INSTANCE = new BasicEntityNameResolver(); - /** - * {@inheritDoc} - */ + @Override public String resolveEntityName(Object entity) { if ( ! Map.class.isInstance( entity ) ) { return null; @@ -244,17 +203,11 @@ public class DynamicMapEntityTuplizer extends AbstractEntityTuplizer { return entityName; } - /** - * {@inheritDoc} - */ @Override public boolean equals(Object obj) { return getClass().equals( obj.getClass() ); } - /** - * {@inheritDoc} - */ @Override public int hashCode() { return getClass().hashCode(); diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java index 3c90c918a6..41945c3436 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java @@ -42,6 +42,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.classic.Lifecycle; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.mapping.PersistentClass; @@ -59,8 +60,6 @@ import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.PojoInstantiator; import org.hibernate.type.CompositeType; -import org.jboss.logging.Logger; - /** * An {@link EntityTuplizer} specific to the pojo entity mode. * @@ -68,8 +67,7 @@ import org.jboss.logging.Logger; * @author Gavin King */ public class PojoEntityTuplizer extends AbstractEntityTuplizer { - - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, PojoEntityTuplizer.class.getName()); + private static final CoreMessageLogger LOG = CoreLogging.messageLogger( PojoEntityTuplizer.class ); private final Class mappedClass; private final Class proxyInterface; @@ -151,9 +149,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) { // determine the id getter and setter methods from the proxy interface (if any) @@ -250,9 +245,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { // return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); } - /** - * {@inheritDoc} - */ @Override protected Instantiator buildInstantiator(PersistentClass persistentClass) { if ( optimizer == null ) { @@ -263,9 +255,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override protected ProxyFactory buildProxyFactory(EntityBinding entityBinding, Getter idGetter, Setter idSetter) { // determine the id getter and setter methods from the proxy interface (if any) @@ -354,9 +343,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { // return getFactory().getSettings().getBytecodeProvider().getProxyFactoryFactory().buildProxyFactory(); } - /** - * {@inheritDoc} - */ @Override protected Instantiator buildInstantiator(EntityBinding entityBinding) { if ( optimizer == null ) { @@ -367,9 +353,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override public void setPropertyValues(Object entity, Object[] values) throws HibernateException { if ( !getEntityMetamodel().hasLazyProperties() && optimizer != null && optimizer.getAccessOptimizer() != null ) { @@ -380,9 +363,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override public Object[] getPropertyValues(Object entity) throws HibernateException { if ( shouldGetAllProperties( entity ) && optimizer != null && optimizer.getAccessOptimizer() != null ) { @@ -393,9 +373,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override public Object[] getPropertyValuesToInsert(Object entity, Map mergeMap, SessionImplementor session) throws HibernateException { if ( shouldGetAllProperties( entity ) && optimizer != null && optimizer.getAccessOptimizer() != null ) { @@ -414,55 +391,36 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { return optimizer.getAccessOptimizer().getPropertyValues( object ); } - /** - * {@inheritDoc} - */ + @Override public EntityMode getEntityMode() { return EntityMode.POJO; } - /** - * {@inheritDoc} - */ + @Override public Class getMappedClass() { return mappedClass; } - /** - * {@inheritDoc} - */ @Override public boolean isLifecycleImplementor() { return lifecycleImplementor; } - /** - * {@inheritDoc} - */ @Override protected Getter buildPropertyGetter(Property mappedProperty, PersistentClass mappedEntity) { return mappedProperty.getGetter( mappedEntity.getMappedClass() ); } - /** - * {@inheritDoc} - */ @Override protected Setter buildPropertySetter(Property mappedProperty, PersistentClass mappedEntity) { return mappedProperty.getSetter( mappedEntity.getMappedClass() ); } - /** - * {@inheritDoc} - */ @Override protected Getter buildPropertyGetter(AttributeBinding mappedProperty) { return getGetter( mappedProperty ); } - /** - * {@inheritDoc} - */ @Override protected Setter buildPropertySetter(AttributeBinding mappedProperty) { return getSetter( mappedProperty ); @@ -490,18 +448,13 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { ); } - /** - * {@inheritDoc} - */ + @Override public Class getConcreteProxyClass() { return proxyInterface; } //TODO: need to make the majority of this functionality into a top-level support class for custom impl support - /** - * {@inheritDoc} - */ @Override public void afterInitialize(Object entity, boolean lazyPropertiesAreUnfetched, SessionImplementor session) { if ( isInstrumented() ) { @@ -518,9 +471,6 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ @Override public boolean hasUninitializedLazyProperties(Object entity) { if ( getEntityMetamodel().hasLazyProperties() ) { @@ -532,16 +482,12 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ + @Override public boolean isInstrumented() { return isInstrumented; } - /** - * {@inheritDoc} - */ + @Override public String determineConcreteSubclassEntityName(Object entityInstance, SessionFactoryImplementor factory) { final Class concreteEntityClass = entityInstance.getClass(); if ( concreteEntityClass == getMappedClass() ) { @@ -559,9 +505,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { } } - /** - * {@inheritDoc} - */ + @Override public EntityNameResolver[] getEntityNameResolvers() { return null; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java b/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java index 86fd6173d2..4b9e08c27b 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/BigDecimalType.java @@ -42,9 +42,7 @@ public class BigDecimalType extends AbstractSingleColumnStandardBasicType { super( org.hibernate.type.descriptor.sql.BlobTypeDescriptor.DEFAULT, BlobTypeDescriptor.INSTANCE ); } - /** - * {@inheritDoc} - */ + @Override public String getName() { return "blob"; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index 8acea51ff4..3a76e13f9b 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -103,6 +103,7 @@ public abstract class CollectionType extends AbstractType implements Association this.isEmbeddedInXML = true; } + @Override public boolean isEmbeddedInXML() { return isEmbeddedInXML; } @@ -131,20 +132,24 @@ public abstract class CollectionType extends AbstractType implements Association return false; } + @Override public boolean isCollectionType() { return true; } + @Override public final boolean isEqual(Object x, Object y) { return x == y || ( x instanceof PersistentCollection && ( (PersistentCollection) x ).isWrapper( y ) ) || ( y instanceof PersistentCollection && ( (PersistentCollection) y ).isWrapper( x ) ); } + @Override public int compare(Object x, Object y) { return 0; // collections cannot be compared } + @Override public int getHashCode(Object x) { throw new UnsupportedOperationException( "cannot doAfterTransactionCompletion lookups on collections" ); } @@ -160,24 +165,29 @@ public abstract class CollectionType extends AbstractType implements Association */ public abstract PersistentCollection instantiate(SessionImplementor session, CollectionPersister persister, Serializable key); + @Override public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) throws SQLException { return nullSafeGet( rs, new String[] { name }, session, owner ); } + @Override public Object nullSafeGet(ResultSet rs, String[] name, SessionImplementor session, Object owner) throws HibernateException, SQLException { return resolve( null, session, owner ); } + @Override public final void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session) throws HibernateException, SQLException { //NOOP } + @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { } + @Override public int[] sqlTypes(Mapping session) throws MappingException { return ArrayHelper.EMPTY_INT_ARRAY; } @@ -192,10 +202,12 @@ public abstract class CollectionType extends AbstractType implements Association return new Size[] { LEGACY_DEFAULT_SIZE }; } + @Override public int getColumnSpan(Mapping session) throws MappingException { return 0; } + @Override public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException { if ( value == null ) { @@ -219,11 +231,13 @@ public abstract class CollectionType extends AbstractType implements Association return list.toString(); } + @Override public Object deepCopy(Object value, SessionFactoryImplementor factory) throws HibernateException { return value; } + @Override public String getName() { return getReturnedClass().getName() + '(' + getRole() + ')'; } @@ -249,10 +263,12 @@ public abstract class CollectionType extends AbstractType implements Association return ( (Collection) collection ).iterator(); } + @Override public boolean isMutable() { return false; } + @Override public Serializable disassemble(Object value, SessionImplementor session, Object owner) throws HibernateException { //remember the uk value @@ -272,6 +288,7 @@ public abstract class CollectionType extends AbstractType implements Association } } + @Override public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { //we must use the "remembered" uk value, since it is @@ -309,6 +326,7 @@ public abstract class CollectionType extends AbstractType implements Association return session.getFactory().getCollectionPersister( role ); } + @Override public boolean isDirty(Object old, Object current, SessionImplementor session) throws HibernateException { @@ -321,6 +339,7 @@ public abstract class CollectionType extends AbstractType implements Association } + @Override public boolean isDirty(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { return isDirty(old, current, session); @@ -340,10 +359,12 @@ public abstract class CollectionType extends AbstractType implements Association * Note: return true because this type is castable to AssociationType. Not because * all collections are associations. */ + @Override public boolean isAssociationType() { return true; } + @Override public ForeignKeyDirection getForeignKeyDirection() { return ForeignKeyDirection.FOREIGN_KEY_TO_PARENT; } @@ -425,12 +446,14 @@ public abstract class CollectionType extends AbstractType implements Association return ownerId; } + @Override public Object hydrate(ResultSet rs, String[] name, SessionImplementor session, Object owner) { // can't just return null here, since that would // cause an owning component to become null return NOT_NULL_COLLECTION; } + @Override public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException { @@ -444,6 +467,7 @@ public abstract class CollectionType extends AbstractType implements Association getCollection( key, session, owner ); } + @Override public Object semiResolve(Object value, SessionImplementor session, Object owner) throws HibernateException { throw new UnsupportedOperationException( @@ -454,23 +478,28 @@ public abstract class CollectionType extends AbstractType implements Association return false; } + @Override public boolean useLHSPrimaryKey() { return foreignKeyPropertyName == null; } + @Override public String getRHSUniqueKeyPropertyName() { return null; } + @Override public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) throws MappingException { return (Joinable) factory.getCollectionPersister( role ); } + @Override public boolean isModified(Object old, Object current, boolean[] checkable, SessionImplementor session) throws HibernateException { return false; } + @Override public String getAssociatedEntityName(SessionFactoryImplementor factory) throws MappingException { try { @@ -638,9 +667,7 @@ public abstract class CollectionType extends AbstractType implements Association */ public abstract Object instantiate(int anticipatedSize); - /** - * {@inheritDoc} - */ + @Override public Object replace( final Object original, final Object target, @@ -688,10 +715,12 @@ public abstract class CollectionType extends AbstractType implements Association return factory.getCollectionPersister( getRole() ).getElementType(); } + @Override public String toString() { return getClass().getName() + '(' + getRole() + ')'; } + @Override public String getOnCondition(String alias, SessionFactoryImplementor factory, Map enabledFilters) throws MappingException { return getAssociatedJoinable( factory ).filterFragment( alias, enabledFilters ); @@ -771,20 +800,24 @@ public abstract class CollectionType extends AbstractType implements Association return false; } + @Override public String getLHSPropertyName() { return foreignKeyPropertyName; } + @Override public boolean isXMLElement() { return true; } + @Override public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException { return xml; } - public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) - throws HibernateException { + @Override + public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) + throws HibernateException { if ( !isEmbeddedInXML ) { node.detach(); } @@ -798,10 +831,12 @@ public abstract class CollectionType extends AbstractType implements Association * need to incremement version number of owner and also because of * how assemble/disassemble is implemented for uks */ + @Override public boolean isAlwaysDirtyChecked() { return true; } + @Override public boolean[] toColumnNullness(Object value, Mapping mapping) { return ArrayHelper.EMPTY_BOOLEAN_ARRAY; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java index ac29b91e00..f7f2f0eeec 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java @@ -155,6 +155,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * * @return True. */ + @Override public boolean isAssociationType() { return true; } @@ -164,13 +165,12 @@ public abstract class EntityType extends AbstractType implements AssociationType * * @return True. */ + @Override public final boolean isEntityType() { return true; } - /** - * {@inheritDoc} - */ + @Override public boolean isMutable() { return false; } @@ -180,6 +180,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * * @return string rep */ + @Override public String toString() { return getClass().getName() + '(' + getAssociatedEntityName() + ')'; } @@ -187,6 +188,7 @@ public abstract class EntityType extends AbstractType implements AssociationType /** * For entity types, the name correlates to the associated entity name. */ + @Override public String getName() { return associatedEntityName; } @@ -201,12 +203,14 @@ public abstract class EntityType extends AbstractType implements AssociationType return referenceToPrimaryKey; } + @Override public String getRHSUniqueKeyPropertyName() { // Return null if this type references a PK. This is important for // associations' use of mappedBy referring to a derived ID. return referenceToPrimaryKey ? null : uniqueKeyPropertyName; } + @Override public String getLHSPropertyName() { return null; } @@ -230,6 +234,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * @param factory The session factory, for resolution. * @return The associated entity name. */ + @Override public String getAssociatedEntityName(SessionFactoryImplementor factory) { return getAssociatedEntityName(); } @@ -241,6 +246,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * @return The associated joinable * @throws MappingException Generally indicates an invalid entity name. */ + @Override public Joinable getAssociatedJoinable(SessionFactoryImplementor factory) throws MappingException { return ( Joinable ) factory.getEntityPersister( associatedEntityName ); } @@ -255,6 +261,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * * @return The entiyt class. */ + @Override public final Class getReturnedClass() { if ( returnedClass == null ) { returnedClass = determineAssociatedEntityClass(); @@ -273,17 +280,13 @@ public abstract class EntityType extends AbstractType implements AssociationType } } - /** - * {@inheritDoc} - */ + @Override public Object nullSafeGet(ResultSet rs, String name, SessionImplementor session, Object owner) - throws HibernateException, SQLException { + throws HibernateException, SQLException { return nullSafeGet( rs, new String[] {name}, session, owner ); } - /** - * {@inheritDoc} - */ + @Override public final Object nullSafeGet( ResultSet rs, String[] names, @@ -300,27 +303,22 @@ public abstract class EntityType extends AbstractType implements AssociationType * @param y Another entity instance * @return True if x == y; false otherwise. */ + @Override public final boolean isSame(Object x, Object y) { return x == y; } - /** - * {@inheritDoc} - */ + @Override public int compare(Object x, Object y) { return 0; //TODO: entities CAN be compared, by PK, fix this! -> only if/when we can extract the id values.... } - /** - * {@inheritDoc} - */ + @Override public Object deepCopy(Object value, SessionFactoryImplementor factory) { return value; //special case ... this is the leaf of the containment graph, even though not immutable } - /** - * {@inheritDoc} - */ + @Override public Object replace( Object original, Object target, @@ -357,9 +355,7 @@ public abstract class EntityType extends AbstractType implements AssociationType } } - /** - * {@inheritDoc} - */ + @Override public int getHashCode(Object x, SessionFactoryImplementor factory) { EntityPersister persister = factory.getEntityPersister(associatedEntityName); if ( !persister.canExtractIdOutOfEntity() ) { @@ -429,23 +425,17 @@ public abstract class EntityType extends AbstractType implements AssociationType .isEqual(xid, yid, factory); } - /** - * {@inheritDoc} - */ + @Override public boolean isEmbeddedInXML() { return isEmbeddedInXML; } - /** - * {@inheritDoc} - */ + @Override public boolean isXMLElement() { return isEmbeddedInXML; } - /** - * {@inheritDoc} - */ + @Override public Object fromXMLNode(Node xml, Mapping factory) throws HibernateException { if ( !isEmbeddedInXML ) { return getIdentifierType(factory).fromXMLNode(xml, factory); @@ -455,9 +445,7 @@ public abstract class EntityType extends AbstractType implements AssociationType } } - /** - * {@inheritDoc} - */ + @Override public void setToXMLNode(Node node, Object value, SessionFactoryImplementor factory) throws HibernateException { if ( !isEmbeddedInXML ) { getIdentifierType(factory).setToXMLNode(node, value, factory); @@ -490,6 +478,7 @@ public abstract class EntityType extends AbstractType implements AssociationType /** * Resolve an identifier or unique key value */ + @Override public Object resolve(Object value, SessionImplementor session, Object owner) throws HibernateException { if ( isNotEmbedded( session ) ) { return value; @@ -507,6 +496,7 @@ public abstract class EntityType extends AbstractType implements AssociationType return null; } + @Override public Type getSemiResolvedType(SessionFactoryImplementor factory) { return factory.getEntityPersister( associatedEntityName ).getIdentifierType(); } @@ -555,6 +545,7 @@ public abstract class EntityType extends AbstractType implements AssociationType * @return The loggable string. * @throws HibernateException Generally some form of resolution problem. */ + @Override public String toLoggableString(Object value, SessionFactoryImplementor factory) { if ( value == null ) { return "null"; diff --git a/hibernate-core/src/main/java/org/hibernate/type/OrderedMapType.java b/hibernate-core/src/main/java/org/hibernate/type/OrderedMapType.java index b00b1eaf4b..40430f7ee4 100755 --- a/hibernate-core/src/main/java/org/hibernate/type/OrderedMapType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/OrderedMapType.java @@ -50,9 +50,7 @@ public class OrderedMapType extends MapType { super( typeScope, role, propertyRef ); } - /** - * {@inheritDoc} - */ + @Override public Object instantiate(int anticipatedSize) { return anticipatedSize > 0 ? new LinkedHashMap( anticipatedSize ) diff --git a/hibernate-core/src/main/java/org/hibernate/type/OrderedSetType.java b/hibernate-core/src/main/java/org/hibernate/type/OrderedSetType.java index b9aae70074..7f798cdc8e 100755 --- a/hibernate-core/src/main/java/org/hibernate/type/OrderedSetType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/OrderedSetType.java @@ -51,9 +51,7 @@ public class OrderedSetType extends SetType { super( typeScope, role, propertyRef ); } - /** - * {@inheritDoc} - */ + @Override public Object instantiate(int anticipatedSize) { return anticipatedSize > 0 ? new LinkedHashSet( anticipatedSize ) diff --git a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java index 702d14f07f..cab5c265c2 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/SerializableToBlobType.java @@ -41,24 +41,16 @@ public class SerializableToBlobType extends AbstractSing private static final long serialVersionUID = 1L; - /** - * @param sqlTypeDescriptor - * @param javaTypeDescriptor - */ public SerializableToBlobType() { super( BlobTypeDescriptor.DEFAULT, new SerializableTypeDescriptor( Serializable.class ) ); } - /** - * {@inheritDoc} - */ + @Override public String getName() { return getClass().getName(); } - /** - * {@inheritDoc} - */ + @Override @SuppressWarnings("unchecked") public void setParameterValues(Properties parameters) { ParameterType reader = (ParameterType) parameters.get( PARAMETER_TYPE ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/BigIntegerTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/BigIntegerTypeDescriptor.java index 18b43195e9..6759c13db7 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/BigIntegerTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/java/BigIntegerTypeDescriptor.java @@ -40,10 +40,12 @@ public class BigIntegerTypeDescriptor extends AbstractTypeDescriptor super( BigInteger.class ); } + @Override public String toString(BigInteger value) { return value.toString(); } + @Override public BigInteger fromString(String string) { return new BigInteger( string ); } @@ -58,9 +60,7 @@ public class BigIntegerTypeDescriptor extends AbstractTypeDescriptor return one == another || ( one != null && another != null && one.compareTo( another ) == 0 ); } - /** - * {@inheritDoc} - */ + @Override @SuppressWarnings({ "unchecked" }) public X unwrap(BigInteger value, Class type, WrapperOptions options) { if ( value == null ) { @@ -93,9 +93,7 @@ public class BigIntegerTypeDescriptor extends AbstractTypeDescriptor throw unknownUnwrap( type ); } - /** - * {@inheritDoc} - */ + @Override public BigInteger wrap(X value, WrapperOptions options) { if ( value == null ) { return null; diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java index 8af63b85c9..a61cab7cd6 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/BlobTypeDescriptor.java @@ -71,7 +71,8 @@ public abstract class BlobTypeDescriptor implements SqlTypeDescriptor { } @Override - protected X doExtract(CallableStatement statement, String name, WrapperOptions options) throws SQLException { + protected X doExtract(CallableStatement statement, String name, WrapperOptions options) + throws SQLException { return javaTypeDescriptor.wrap( statement.getBlob( name ), options ); } }; @@ -79,76 +80,78 @@ public abstract class BlobTypeDescriptor implements SqlTypeDescriptor { protected abstract BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor); + @Override public BasicBinder getBinder(final JavaTypeDescriptor javaTypeDescriptor) { return getBlobBinder( javaTypeDescriptor ); } - public static final BlobTypeDescriptor DEFAULT = - new BlobTypeDescriptor() { - { - SqlTypeDescriptorRegistry.INSTANCE.addDescriptor( this ); - } + public static final BlobTypeDescriptor DEFAULT = new BlobTypeDescriptor() { + { + SqlTypeDescriptorRegistry.INSTANCE.addDescriptor( this ); + } + @Override + public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicBinder( javaTypeDescriptor, this ) { @Override - public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicBinder( javaTypeDescriptor, this ) { - @Override - protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) throws SQLException { - BlobTypeDescriptor descriptor = BLOB_BINDING; - if ( byte[].class.isInstance( value ) ) { - // performance shortcut for binding BLOB data in byte[] format - descriptor = PRIMITIVE_ARRAY_BINDING; - } - else if ( options.useStreamForLobBinding() ) { - descriptor = STREAM_BINDING; - } - descriptor.getBlobBinder( javaTypeDescriptor ).doBind( st, value, index, options ); - } - }; + protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) + throws SQLException { + BlobTypeDescriptor descriptor = BLOB_BINDING; + if ( byte[].class.isInstance( value ) ) { + // performance shortcut for binding BLOB data in byte[] format + descriptor = PRIMITIVE_ARRAY_BINDING; + } + else if ( options.useStreamForLobBinding() ) { + descriptor = STREAM_BINDING; + } + descriptor.getBlobBinder( javaTypeDescriptor ).doBind( st, value, index, options ); } }; + } + }; - public static final BlobTypeDescriptor PRIMITIVE_ARRAY_BINDING = - new BlobTypeDescriptor() { + public static final BlobTypeDescriptor PRIMITIVE_ARRAY_BINDING = new BlobTypeDescriptor() { + @Override + public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicBinder( javaTypeDescriptor, this ) { @Override - public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicBinder( javaTypeDescriptor, this ) { - @Override - public void doBind(PreparedStatement st, X value, int index, WrapperOptions options) - throws SQLException { - st.setBytes( index, javaTypeDescriptor.unwrap( value, byte[].class, options ) ); - } - }; + public void doBind(PreparedStatement st, X value, int index, WrapperOptions options) + throws SQLException { + st.setBytes( index, javaTypeDescriptor.unwrap( value, byte[].class, options ) ); } }; + } + }; - public static final BlobTypeDescriptor BLOB_BINDING = - new BlobTypeDescriptor() { + public static final BlobTypeDescriptor BLOB_BINDING = new BlobTypeDescriptor() { + @Override + public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicBinder( javaTypeDescriptor, this ) { @Override - public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicBinder( javaTypeDescriptor, this ) { - @Override - protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) - throws SQLException { - st.setBlob( index, javaTypeDescriptor.unwrap( value, Blob.class, options ) ); - } - }; + protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) + throws SQLException { + st.setBlob( index, javaTypeDescriptor.unwrap( value, Blob.class, options ) ); } }; + } + }; - public static final BlobTypeDescriptor STREAM_BINDING = - new BlobTypeDescriptor() { + public static final BlobTypeDescriptor STREAM_BINDING = new BlobTypeDescriptor() { + @Override + public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { + return new BasicBinder( javaTypeDescriptor, this ) { @Override - public BasicBinder getBlobBinder(final JavaTypeDescriptor javaTypeDescriptor) { - return new BasicBinder( javaTypeDescriptor, this ) { - @Override - protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) - throws SQLException { - final BinaryStream binaryStream = javaTypeDescriptor.unwrap( value, BinaryStream.class, options ); - st.setBinaryStream( index, binaryStream.getInputStream(), binaryStream.getLength() ); - } - }; + protected void doBind(PreparedStatement st, X value, int index, WrapperOptions options) + throws SQLException { + final BinaryStream binaryStream = javaTypeDescriptor.unwrap( + value, + BinaryStream.class, + options + ); + st.setBinaryStream( index, binaryStream.getInputStream(), binaryStream.getLength() ); } }; + } + }; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java index fb8fb6b6e5..8705bc3819 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/HQLTest.java @@ -103,7 +103,7 @@ public class HQLTest extends QueryTranslatorTestCase { protected void prepareTest() throws Exception { super.prepareTest(); SelectClause.VERSION2_SQL = true; - DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = true; + DotNode.regressionStyleJoinSuppression = true; DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER = new DotNode.IllegalCollectionDereferenceExceptionBuilder() { public QueryException buildIllegalCollectionDereferenceException(String propertyName, FromReferenceNode lhs) { throw new QueryException( "illegal syntax near collection: " + propertyName ); @@ -115,7 +115,7 @@ public class HQLTest extends QueryTranslatorTestCase { @Override protected void cleanupTest() throws Exception { SelectClause.VERSION2_SQL = false; - DotNode.REGRESSION_STYLE_JOIN_SUPPRESSION = false; + DotNode.regressionStyleJoinSuppression = false; DotNode.ILLEGAL_COLL_DEREF_EXCP_BUILDER = DotNode.DEF_ILLEGAL_COLL_DEREF_EXCP_BUILDER; SqlGenerator.REGRESSION_STYLE_CROSS_JOINS = false; super.cleanupTest(); diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java index fda32b340c..fd30a8b062 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/boot/internal/EntityManagerFactoryBuilderImpl.java @@ -541,39 +541,35 @@ public class EntityManagerFactoryBuilderImpl implements EntityManagerFactoryBuil } ); - { - final String cfgXmlResourceName = (String) merged.remove( AvailableSettings.CFG_FILE ); - if ( StringHelper.isNotEmpty( cfgXmlResourceName ) ) { - // it does, so load those properties - JaxbHibernateConfiguration configurationElement = configLoaderHolder.getValue() - .loadConfigXmlResource( cfgXmlResourceName ); - processHibernateConfigurationElement( configurationElement, merged ); - } + final String cfgXmlResourceName1 = (String) merged.remove( AvailableSettings.CFG_FILE ); + if ( StringHelper.isNotEmpty( cfgXmlResourceName1 ) ) { + // it does, so load those properties + JaxbHibernateConfiguration configurationElement = configLoaderHolder.getValue() + .loadConfigXmlResource( cfgXmlResourceName1 ); + processHibernateConfigurationElement( configurationElement, merged ); } // see if integration settings named a Hibernate config file.... - { - final String cfgXmlResourceName = (String) integrationSettings.get( AvailableSettings.CFG_FILE ); - if ( StringHelper.isNotEmpty( cfgXmlResourceName ) ) { - integrationSettings.remove( AvailableSettings.CFG_FILE ); - // it does, so load those properties - JaxbHibernateConfiguration configurationElement = configLoaderHolder.getValue().loadConfigXmlResource( - cfgXmlResourceName - ); - processHibernateConfigurationElement( configurationElement, merged ); - } + final String cfgXmlResourceName2 = (String) integrationSettings.get( AvailableSettings.CFG_FILE ); + if ( StringHelper.isNotEmpty( cfgXmlResourceName2 ) ) { + integrationSettings.remove( AvailableSettings.CFG_FILE ); + // it does, so load those properties + JaxbHibernateConfiguration configurationElement = configLoaderHolder.getValue().loadConfigXmlResource( + cfgXmlResourceName2 + ); + processHibernateConfigurationElement( configurationElement, merged ); } // finally, apply integration-supplied settings (per JPA spec, integration settings should override other sources) merged.putAll( integrationSettings ); - if ( ! merged.containsKey( AvailableSettings.VALIDATION_MODE ) ) { + if ( !merged.containsKey( AvailableSettings.VALIDATION_MODE ) ) { if ( persistenceUnit.getValidationMode() != null ) { merged.put( AvailableSettings.VALIDATION_MODE, persistenceUnit.getValidationMode() ); } } - if ( ! merged.containsKey( AvailableSettings.SHARED_CACHE_MODE ) ) { + if ( !merged.containsKey( AvailableSettings.SHARED_CACHE_MODE ) ) { if ( persistenceUnit.getSharedCacheMode() != null ) { merged.put( AvailableSettings.SHARED_CACHE_MODE, persistenceUnit.getSharedCacheMode() ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/BinaryArithmeticOperation.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/BinaryArithmeticOperation.java index 9243ac66ab..f3c45a3299 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/BinaryArithmeticOperation.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/BinaryArithmeticOperation.java @@ -43,48 +43,50 @@ public class BinaryArithmeticOperation public static enum Operation { ADD { + @Override String apply(String lhs, String rhs) { return applyPrimitive( lhs, '+', rhs ); } }, SUBTRACT { + @Override String apply(String lhs, String rhs) { return applyPrimitive( lhs, '-', rhs ); } }, MULTIPLY { + @Override String apply(String lhs, String rhs) { return applyPrimitive( lhs, '*', rhs ); } }, DIVIDE { + @Override String apply(String lhs, String rhs) { return applyPrimitive( lhs, '/', rhs ); } }, QUOT { + @Override String apply(String lhs, String rhs) { return applyPrimitive( lhs, '/', rhs ); } }, MOD { + @Override String apply(String lhs, String rhs) { // return lhs + " % " + rhs; return "mod(" + lhs + "," + rhs + ")"; } }; + abstract String apply(String lhs, String rhs); private static final char LEFT_PAREN = '('; private static final char RIGHT_PAREN = ')'; + private static String applyPrimitive(String lhs, char operator, String rhs) { - return new StringBuffer( lhs.length() + rhs.length() + 3 ) - .append( LEFT_PAREN ) - .append( lhs ) - .append( operator ) - .append( rhs ) - .append( RIGHT_PAREN ) - .toString(); + return String.valueOf( LEFT_PAREN ) + lhs + operator + rhs + RIGHT_PAREN; } } @@ -102,8 +104,7 @@ public class BinaryArithmeticOperation public static Class determineResultType( Class argument1Type, Class argument2Type, - boolean isQuotientOperation - ) { + boolean isQuotientOperation) { if ( isQuotientOperation ) { return Number.class; } @@ -206,28 +207,23 @@ public class BinaryArithmeticOperation return operator; } - /** - * {@inheritDoc} - */ + @Override public Expression getRightHandOperand() { return rhs; } - /** - * {@inheritDoc} - */ + @Override public Expression getLeftHandOperand() { return lhs; } - /** - * {@inheritDoc} - */ + @Override public void registerParameters(ParameterRegistry registry) { Helper.possibleParameter( getRightHandOperand(), registry ); Helper.possibleParameter( getLeftHandOperand(), registry ); } + @Override public String render(RenderingContext renderingContext) { return getOperator().apply( ( (Renderable) getLeftHandOperand() ).render( renderingContext ), @@ -235,6 +231,7 @@ public class BinaryArithmeticOperation ); } + @Override public String renderProjection(RenderingContext renderingContext) { return render( renderingContext ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/UnaryArithmeticOperation.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/UnaryArithmeticOperation.java index 9ad9ecde78..cdf94052a4 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/UnaryArithmeticOperation.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/expression/UnaryArithmeticOperation.java @@ -61,25 +61,23 @@ public class UnaryArithmeticOperation return operation; } - /** - * {@inheritDoc} - */ + @Override public Expression getOperand() { return operand; } - /** - * {@inheritDoc} - */ + @Override public void registerParameters(ParameterRegistry registry) { Helper.possibleParameter( getOperand(), registry ); } + @Override public String render(RenderingContext renderingContext) { return ( getOperation() == Operation.UNARY_MINUS ? '-' : '+' ) + ( (Renderable) getOperand() ).render( renderingContext ); } + @Override public String renderProjection(RenderingContext renderingContext) { return render( renderingContext ); } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/AbstractAttribute.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/AbstractAttribute.java index bde7596a13..726f410977 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/AbstractAttribute.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/AbstractAttribute.java @@ -60,37 +60,27 @@ public abstract class AbstractAttribute this.persistentAttributeType = persistentAttributeType; } - /** - * {@inheritDoc} - */ + @Override public String getName() { return name; } - /** - * {@inheritDoc} - */ + @Override public ManagedType getDeclaringType() { return declaringType; } - /** - * {@inheritDoc} - */ + @Override public Class getJavaType() { return javaType; } - /** - * {@inheritDoc} - */ + @Override public Member getJavaMember() { return member; } - /** - * {@inheritDoc} - */ + @Override public PersistentAttributeType getPersistentAttributeType() { return persistentAttributeType; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/PluralAttributeImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/PluralAttributeImpl.java index 63b4a27b6b..7c9fb05f8f 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/PluralAttributeImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/internal/metamodel/PluralAttributeImpl.java @@ -154,37 +154,27 @@ public abstract class PluralAttributeImpl return new Builder(ownerType, attrType, collectionClass, keyType); } - /** - * {@inheritDoc} - */ + @Override public Type getElementType() { return elementType; } - /** - * {@inheritDoc} - */ + @Override public boolean isAssociation() { return true; } - /** - * {@inheritDoc} - */ + @Override public boolean isCollection() { return true; } - /** - * {@inheritDoc} - */ + @Override public BindableType getBindableType() { return BindableType.PLURAL_ATTRIBUTE; } - /** - * {@inheritDoc} - */ + @Override public Class getBindableJavaType() { return elementType.getJavaType(); } @@ -194,9 +184,7 @@ public abstract class PluralAttributeImpl super( xceBuilder ); } - /** - * {@inheritDoc} - */ + @Override public CollectionType getCollectionType() { return CollectionType.SET; } @@ -207,9 +195,7 @@ public abstract class PluralAttributeImpl super( xceBuilder ); } - /** - * {@inheritDoc} - */ + @Override public CollectionType getCollectionType() { return CollectionType.COLLECTION; } @@ -220,9 +206,7 @@ public abstract class PluralAttributeImpl super( xceBuilder ); } - /** - * {@inheritDoc} - */ + @Override public CollectionType getCollectionType() { return CollectionType.LIST; } @@ -236,23 +220,17 @@ public abstract class PluralAttributeImpl this.keyType = xceBuilder.keyType; } - /** - * {@inheritDoc} - */ + @Override public CollectionType getCollectionType() { return CollectionType.MAP; } - /** - * {@inheritDoc} - */ + @Override public Class getKeyJavaType() { return keyType.getJavaType(); } - /** - * {@inheritDoc} - */ + @Override public Type getKeyType() { return keyType; } diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java index b9da64968b..91ec23e255 100755 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/spi/AbstractEntityManagerImpl.java @@ -775,20 +775,14 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage final SessionFactoryImplementor sfi = entityManagerFactory.getSessionFactory(); - // first try as hql/jpql query - { - final NamedQueryDefinition namedQueryDefinition = sfi.getNamedQueryRepository().getNamedQueryDefinition( name ); - if ( namedQueryDefinition != null ) { - return createNamedJpqlQuery( namedQueryDefinition, resultType ); - } + final NamedQueryDefinition jpqlDefinition = sfi.getNamedQueryRepository().getNamedQueryDefinition( name ); + if ( jpqlDefinition != null ) { + return createNamedJpqlQuery( jpqlDefinition, resultType ); } - // then as a native (SQL) query - { - final NamedSQLQueryDefinition namedQueryDefinition = sfi.getNamedQueryRepository().getNamedSQLQueryDefinition( name ); - if ( namedQueryDefinition != null ) { - return createNamedSqlQuery( namedQueryDefinition, resultType ); - } + final NamedSQLQueryDefinition nativeQueryDefinition = sfi.getNamedQueryRepository().getNamedSQLQueryDefinition( name ); + if ( nativeQueryDefinition != null ) { + return createNamedSqlQuery( nativeQueryDefinition, resultType ); } throw convert( new IllegalArgumentException( "No query defined for that name [" + name + "]" ) ); @@ -1247,9 +1241,9 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage public void refresh(Object entity, LockModeType lockModeType, Map properties) { checkOpen(); - Session session = internalGetSession(); - CacheMode previousCacheMode = session.getCacheMode(); - CacheMode localCacheMode = determineAppropriateLocalCacheMode( properties ); + final Session session = internalGetSession(); + final CacheMode previousCacheMode = session.getCacheMode(); + final CacheMode localCacheMode = determineAppropriateLocalCacheMode( properties ); LockOptions lockOptions = null; try { session.setCacheMode( localCacheMode ); @@ -1737,10 +1731,10 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage handlePersistenceException( converted ); return converted; } - else if ( e instanceof org.hibernate.NonUniqueObjectException ) { + else if ( e instanceof org.hibernate.NonUniqueObjectException ) { final EntityExistsException converted = new EntityExistsException( e.getMessage() ); - handlePersistenceException( converted ); - return converted; + handlePersistenceException( converted ); + return converted; } else if ( e instanceof org.hibernate.NonUniqueResultException ) { final NonUniqueResultException converted = new NonUniqueResultException( e.getMessage() ); @@ -1761,7 +1755,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage } catch ( Exception ne ) { //we do not want the subsequent exception to swallow the original one - LOG.unableToMarkForRollbackOnTransientObjectException(ne); + LOG.unableToMarkForRollbackOnTransientObjectException( ne ); } return new IllegalStateException( e ); //Spec 3.2.3 Synchronization rules } @@ -1781,7 +1775,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage public PersistenceException wrapStaleStateException(StaleStateException e) { PersistenceException pe; if ( e instanceof StaleObjectStateException ) { - final StaleObjectStateException sose = ( StaleObjectStateException ) e; + final StaleObjectStateException sose = (StaleObjectStateException) e; final Serializable identifier = sose.getIdentifier(); if ( identifier != null ) { try { @@ -1828,7 +1822,7 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage } } else if ( e instanceof org.hibernate.PessimisticLockException ) { - final org.hibernate.PessimisticLockException jdbcLockException = ( org.hibernate.PessimisticLockException ) e; + final org.hibernate.PessimisticLockException jdbcLockException = (org.hibernate.PessimisticLockException) e; if ( lockOptions != null && lockOptions.getTimeOut() > -1 ) { // assume lock timeout occurred if a timeout or NO WAIT was specified pe = new LockTimeoutException( jdbcLockException.getMessage(), jdbcLockException, null ); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/cache/AbstractReadWriteAccessStrategy.java b/hibernate-testing/src/main/java/org/hibernate/testing/cache/AbstractReadWriteAccessStrategy.java index 25fc512856..966f920f79 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/cache/AbstractReadWriteAccessStrategy.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/cache/AbstractReadWriteAccessStrategy.java @@ -87,6 +87,7 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy /** * Soft-lock a cache item. */ + @Override public final SoftLock lockItem(Object key, Object version) throws CacheException { try { @@ -110,6 +111,7 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy /** * Soft-unlock a cache item. */ + @Override public final void unlockItem(Object key, SoftLock lock) throws CacheException { try { @@ -205,37 +207,27 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy this.timestamp = timestamp; } - /** - * {@inheritDoc} - */ + @Override public boolean isReadable(long txTimestamp) { return txTimestamp > timestamp; } - /** - * {@inheritDoc} - */ + @Override public boolean isWriteable(long txTimestamp, Object newVersion, Comparator versionComparator) { return version != null && versionComparator.compare( version, newVersion ) < 0; } - /** - * {@inheritDoc} - */ + @Override public Object getValue() { return value; } - /** - * {@inheritDoc} - */ + @Override public boolean isUnlockable(SoftLock lock) { return false; } - /** - * {@inheritDoc} - */ + @Override public Lock lock(long timeout, UUID uuid, long lockId) { return new Lock( timeout, uuid, lockId, version ); } @@ -267,16 +259,12 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy this.sourceUuid = sourceUuid; } - /** - * {@inheritDoc} - */ + @Override public boolean isReadable(long txTimestamp) { return false; } - /** - * {@inheritDoc} - */ + @Override public boolean isWriteable(long txTimestamp, Object newVersion, Comparator versionComparator) { if ( txTimestamp > timeout ) { // if timedout then allow write @@ -292,23 +280,16 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy ) < 0; } - /** - * {@inheritDoc} - */ + @Override public Object getValue() { return null; } - /** - * {@inheritDoc} - */ + @Override public boolean isUnlockable(SoftLock lock) { return equals( lock ); } - /** - * {@inheritDoc} - */ @Override public boolean equals(Object o) { if ( o == this ) { @@ -322,9 +303,6 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy } } - /** - * {@inheritDoc} - */ @Override public int hashCode() { int hash = ( sourceUuid != null ? sourceUuid.hashCode() : 0 ); @@ -342,9 +320,7 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy return concurrent; } - /** - * {@inheritDoc} - */ + @Override public Lock lock(long timeout, UUID uuid, long lockId) { concurrent = true; multiplicity++; @@ -361,9 +337,7 @@ abstract class AbstractReadWriteAccessStrategy extends BaseRegionAccessStrategy } } - /** - * {@inheritDoc} - */ + @Override public String toString() { StringBuilder sb = new StringBuilder( "Lock Source-UUID:" + sourceUuid + " Lock-ID:" + lockId ); return sb.toString(); diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/cache/TransactionalEntityRegionAccessStrategy.java b/hibernate-testing/src/main/java/org/hibernate/testing/cache/TransactionalEntityRegionAccessStrategy.java index a8098a2fa4..376b284360 100644 --- a/hibernate-testing/src/main/java/org/hibernate/testing/cache/TransactionalEntityRegionAccessStrategy.java +++ b/hibernate-testing/src/main/java/org/hibernate/testing/cache/TransactionalEntityRegionAccessStrategy.java @@ -11,33 +11,22 @@ class TransactionalEntityRegionAccessStrategy extends BaseEntityRegionAccessStra super( region ); } - /** - * {@inheritDoc} - */ + @Override public boolean afterInsert(Object key, Object value, Object version) { return false; } - /** - * {@inheritDoc} - */ + @Override public boolean afterUpdate(Object key, Object value, Object currentVersion, Object previousVersion, SoftLock lock) { return false; } - - /** - * {@inheritDoc} - */ @Override public void remove(Object key) throws CacheException { evict( key ); } - - /** - * {@inheritDoc} - */ + @Override public boolean update(Object key, Object value, Object currentVersion, Object previousVersion) throws CacheException { return insert( key, value, currentVersion );