HHH-11944 Rename getDelegate() methods to delegate() following a

discussion with Steve.

They are all new in 5.2.11 so it shouldn't raise any compatibility
issues.

Note that we still have a getDelegate() method in
SessionDelegatorBaseImpl as it is the one coming from EntityManager.
This commit is contained in:
Guillaume Smet 2017-08-30 14:27:23 +02:00
parent 12dd8522be
commit 9fd9f623cb
11 changed files with 48 additions and 12 deletions

View File

@ -48,6 +48,10 @@ public abstract class AbstractDelegatingMetadata implements MetadataImplementor
this.delegate = delegate;
}
protected MetadataImplementor delegate() {
return delegate;
}
@Override
public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
return delegate.getIdentifierGeneratorFactory();

View File

@ -45,10 +45,20 @@ public abstract class AbstractDelegatingMetadataBuilderImplementor<T extends Met
private final MetadataBuilderImplementor delegate;
/**
* Kept for compatibility reason but should be removed as soon as possible.
*
* @deprecated use {@link #delegate()} instead
*/
@Deprecated
public MetadataBuilderImplementor getDelegate() {
return delegate;
}
protected MetadataBuilderImplementor delegate() {
return delegate;
}
public AbstractDelegatingMetadataBuilderImplementor(MetadataBuilderImplementor delegate) {
this.delegate = delegate;
}

View File

@ -44,6 +44,10 @@ public abstract class AbstractDelegatingMetadataBuildingOptions implements Metad
this.delegate = delegate;
}
protected MetadataBuildingOptions delegate() {
return delegate;
}
@Override
public StandardServiceRegistry getServiceRegistry() {
return delegate.getServiceRegistry();

View File

@ -53,7 +53,7 @@ public abstract class AbstractDelegatingSessionFactoryBuilder<T extends SessionF
*/
protected abstract T getThis();
protected SessionFactoryBuilder getDelegate() {
protected SessionFactoryBuilder delegate() {
return delegate;
}

View File

@ -21,23 +21,23 @@ public abstract class AbstractDelegatingSessionFactoryBuilderImplementor<T exten
}
@Override
protected SessionFactoryBuilderImplementor getDelegate() {
return (SessionFactoryBuilderImplementor) super.getDelegate();
protected SessionFactoryBuilderImplementor delegate() {
return (SessionFactoryBuilderImplementor) super.delegate();
}
@SuppressWarnings("deprecation")
@Override
public void markAsJpaBootstrap() {
getDelegate().markAsJpaBootstrap();
delegate().markAsJpaBootstrap();
}
@Override
public void disableJtaTransactionAccess() {
getDelegate().disableJtaTransactionAccess();
delegate().disableJtaTransactionAccess();
}
@Override
public SessionFactoryOptions buildSessionFactoryOptions() {
return getDelegate().buildSessionFactoryOptions();
return delegate().buildSessionFactoryOptions();
}
}

View File

@ -44,6 +44,10 @@ public class AbstractDelegatingSessionFactoryOptions implements SessionFactoryOp
this.delegate = delegate;
}
protected SessionFactoryOptions delegate() {
return delegate;
}
@Override
public StandardServiceRegistry getServiceRegistry() {
return delegate.getServiceRegistry();

View File

@ -38,7 +38,7 @@ public abstract class AbstractDelegatingSessionBuilder<T extends SessionBuilder>
return (T) this;
}
protected SessionBuilder getDelegate() {
protected SessionBuilder delegate() {
return delegate;
}

View File

@ -20,14 +20,14 @@ public abstract class AbstractDelegatingSessionBuilderImplementor<T extends Sess
super( delegate );
}
protected SessionBuilderImplementor getDelegate() {
return (SessionBuilderImplementor) super.getDelegate();
protected SessionBuilderImplementor delegate() {
return (SessionBuilderImplementor) super.delegate();
}
@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public T owner(SessionOwner sessionOwner) {
getDelegate().owner( sessionOwner );
delegate().owner( sessionOwner );
return (T) this;
}
}

View File

@ -40,7 +40,7 @@ public abstract class AbstractDelegatingSharedSessionBuilder<T extends SharedSes
return (T) this;
}
public SharedSessionBuilder getDelegate() {
public SharedSessionBuilder delegate() {
return delegate;
}

View File

@ -104,6 +104,16 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
this( delegate, delegate );
}
/**
* Returns the underlying delegate. Be careful that is has a different behavior from the {@link #getDelegate()}
* method coming from the EntityManager interface which returns the current session.
*
* @see SessionDelegatorBaseImpl#getDelegate()
*/
protected SessionImplementor delegate() {
return delegate;
}
@Override
public <T> T execute(Callback<T> callback) {
return delegate.execute( callback );
@ -622,6 +632,10 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
* This is an implementation of EntityManager#getDelegate(). It returns the current session and not the delegate
* session as it is what we want. The name of the method is misleading here but, as it is part of JPA, we cannot do
* anything about it.
* <p>
* To get the underlying delegate, use {@link #delegate()} instead.
*
* @see SessionDelegatorBaseImpl#delegate()
*/
@Override
public Object getDelegate() {

View File

@ -73,7 +73,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
this.delegate = delegate;
}
protected SessionFactoryImplementor getDelegate() {
protected SessionFactoryImplementor delegate() {
return delegate;
}