HHH-18196 - Remove Session#save / Session#update / Session#saveOrUpdate

HHH-18428 - Remove Session#delete

Javadoc fix-ups
This commit is contained in:
Steve Ebersole 2024-07-29 15:15:17 -05:00
parent d8c2ca7824
commit f170d5637f
13 changed files with 23 additions and 51 deletions

View File

@ -309,7 +309,6 @@ default void onDelete(Object entity, Serializable id, Object[] state, String[] p
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback. * @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
* *
* @see Session#remove(Object) * @see Session#remove(Object)
* @see Session#delete(Object)
* *
* @deprecated Use {@link #onRemove(Object, Object, Object[], String[], Type[])} * @deprecated Use {@link #onRemove(Object, Object, Object[], String[], Type[])}
*/ */

View File

@ -23,8 +23,6 @@
* <p> * <p>
* *
* @author Steve Ebersole * @author Steve Ebersole
*
* @see SelectBeforeUpdate
*/ */
@Target( TYPE ) @Target( TYPE )
@Retention( RUNTIME ) @Retention( RUNTIME )

View File

@ -720,10 +720,11 @@ public interface SessionFactoryBuilder {
SessionFactoryBuilder enableJpaListCompliance(boolean enabled); SessionFactoryBuilder enableJpaListCompliance(boolean enabled);
/** /**
* @see JpaCompliance#isJpaCascadeComplianceEnabled() * @deprecated No longer has any effect.
* *
* @see org.hibernate.cfg.AvailableSettings#JPA_CASCADE_COMPLIANCE * @see JpaCompliance#isJpaCascadeComplianceEnabled()
*/ */
@Deprecated(since = "7.0", forRemoval = true)
SessionFactoryBuilder enableJpaCascadeCompliance(boolean enabled); SessionFactoryBuilder enableJpaCascadeCompliance(boolean enabled);
/** /**

View File

@ -63,17 +63,10 @@ public interface JpaComplianceSettings {
String JPA_QUERY_COMPLIANCE = "hibernate.jpa.compliance.query"; String JPA_QUERY_COMPLIANCE = "hibernate.jpa.compliance.query";
/** /**
* Controls whether Hibernate applies cascade * @deprecated No longer has any effect. Since 7.0 (and removal of save/update processing),
* {@link jakarta.persistence.CascadeType#PERSIST} or * Hibernate always cascades {@linkplain jakarta.persistence.CascadeType#PERSIST PERSIST}
* {@link org.hibernate.annotations.CascadeType#SAVE_UPDATE}
* at flush time. If enabled, Hibernate will cascade the standard
* JPA {@code PERSIST} operation. Otherwise, Hibernate will cascade
* the legacy {@code SAVE_UPDATE} operation.
*
* @settingDefault {@link #JPA_COMPLIANCE}
*
* @since 6.6
*/ */
@Deprecated
String JPA_CASCADE_COMPLIANCE = "hibernate.jpa.compliance.cascade"; String JPA_CASCADE_COMPLIANCE = "hibernate.jpa.compliance.cascade";
/** /**

View File

@ -80,11 +80,11 @@ public String toString() {
}; };
/** /**
* @see org.hibernate.Session#delete(Object) * Used in legacy {@code Session#delete} method, which has been removed
* *
* @deprecated Use {@link #REMOVE} * @deprecated Use {@link #REMOVE}
*/ */
@Deprecated(since = "6.6") @Deprecated(since = "6.6", forRemoval = true)
public static final CascadingAction<DeleteContext> DELETE = REMOVE; public static final CascadingAction<DeleteContext> DELETE = REMOVE;
/** /**

View File

@ -53,11 +53,8 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, AbstractFlushingEventListener.class.getName() ); private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, AbstractFlushingEventListener.class.getName() );
private boolean jpaBootstrap;
@Override @Override
public void wasJpaBootstrap(boolean wasJpaBootstrap) { public void wasJpaBootstrap(boolean wasJpaBootstrap) {
this.jpaBootstrap = wasJpaBootstrap;
} }
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -205,10 +202,6 @@ protected CascadingAction<PersistContext> getCascadingAction(EventSource session
return CascadingActions.PERSIST_ON_FLUSH; return CascadingActions.PERSIST_ON_FLUSH;
} }
private static boolean isJpaCascadeComplianceEnabled(EventSource session) {
return session.getSessionFactory().getSessionFactoryOptions().getJpaCompliance().isJpaCascadeComplianceEnabled();
}
/** /**
* Initialize the flags of the CollectionEntry, including the * Initialize the flags of the CollectionEntry, including the
* dirty check. * dirty check.
@ -284,14 +277,13 @@ private FlushEntityEvent createOrReuseEventInstance(
EventSource source, EventSource source,
Object key, Object key,
EntityEntry entry) { EntityEntry entry) {
final FlushEntityEvent entityEvent = possiblyValidExistingInstance; if ( possiblyValidExistingInstance == null || !possiblyValidExistingInstance.isAllowedToReuse() ) {
if ( entityEvent == null || !entityEvent.isAllowedToReuse() ) {
//need to create a new instance //need to create a new instance
return new FlushEntityEvent( source, key, entry ); return new FlushEntityEvent( source, key, entry );
} }
else { else {
entityEvent.resetAndReuseEventInstance( key, entry ); possiblyValidExistingInstance.resetAndReuseEventInstance( key, entry );
return entityEvent; return possiblyValidExistingInstance;
} }
} }

View File

@ -8,11 +8,15 @@
import java.util.IdentityHashMap; import java.util.IdentityHashMap;
import org.hibernate.event.internal.DefaultDeleteEventListener;
/** /**
* A {@link DeleteEvent} represents a {@linkplain org.hibernate.Session#delete(Object) delete operation} * A {@link DeleteEvent} represents a {@linkplain org.hibernate.Session#remove delete operation}
* applied to a single entity. A {@code DeleteContext} is propagated across all cascaded delete operations, * applied to a single entity. A {@code DeleteContext} is propagated across all cascaded delete operations,
* and keeps track of all the entities we've already visited. * and keeps track of all the entities we've already visited.
* *
* @see DefaultDeleteEventListener#onDelete(DeleteEvent, DeleteContext)
*
* @author Gavin King * @author Gavin King
*/ */
public interface DeleteContext { public interface DeleteContext {

View File

@ -26,7 +26,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
private boolean closedCompliance; private boolean closedCompliance;
private boolean cachingCompliance; private boolean cachingCompliance;
private boolean loadByIdCompliance; private boolean loadByIdCompliance;
private boolean cascadeCompliance;
public MutableJpaComplianceImpl(Map<?,?> configurationSettings) { public MutableJpaComplianceImpl(Map<?,?> configurationSettings) {
this( this(
@ -39,11 +38,6 @@ public MutableJpaComplianceImpl(Map<?,?> configurationSettings) {
public MutableJpaComplianceImpl(Map<?,?> configurationSettings, boolean jpaByDefault) { public MutableJpaComplianceImpl(Map<?,?> configurationSettings, boolean jpaByDefault) {
final Object legacyQueryCompliance = configurationSettings.get( AvailableSettings.JPAQL_STRICT_COMPLIANCE ); final Object legacyQueryCompliance = configurationSettings.get( AvailableSettings.JPAQL_STRICT_COMPLIANCE );
cascadeCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_CASCADE_COMPLIANCE,
configurationSettings,
jpaByDefault
);
//noinspection deprecation //noinspection deprecation
listCompliance = ConfigurationHelper.getBoolean( listCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_LIST_COMPLIANCE, AvailableSettings.JPA_LIST_COMPLIANCE,
@ -103,7 +97,7 @@ public boolean isJpaTransactionComplianceEnabled() {
} }
public boolean isJpaCascadeComplianceEnabled() { public boolean isJpaCascadeComplianceEnabled() {
return cascadeCompliance; return true;
} }
@Override @Override
@ -151,7 +145,6 @@ public void setListCompliance(boolean listCompliance) {
@Override @Override
public void setCascadeCompliance(boolean cascadeCompliance) { public void setCascadeCompliance(boolean cascadeCompliance) {
this.cascadeCompliance = cascadeCompliance;
} }
@Override @Override
@ -197,7 +190,6 @@ public void setLoadByIdCompliance(boolean enabled) {
public JpaCompliance immutableCopy() { public JpaCompliance immutableCopy() {
JpaComplianceImpl.JpaComplianceBuilder builder = new JpaComplianceImpl.JpaComplianceBuilder(); JpaComplianceImpl.JpaComplianceBuilder builder = new JpaComplianceImpl.JpaComplianceBuilder();
builder = builder.setListCompliance( listCompliance ) builder = builder.setListCompliance( listCompliance )
.setCascadeCompliance( cascadeCompliance )
.setProxyCompliance( proxyCompliance ) .setProxyCompliance( proxyCompliance )
.setOrderByMappingCompliance( orderByMappingCompliance ) .setOrderByMappingCompliance( orderByMappingCompliance )
.setGlobalGeneratorNameCompliance( generatorNameScopeCompliance ) .setGlobalGeneratorNameCompliance( generatorNameScopeCompliance )

View File

@ -81,14 +81,9 @@ public interface JpaCompliance {
boolean isJpaClosedComplianceEnabled(); boolean isJpaClosedComplianceEnabled();
/** /**
* JPA specifies that a {@link jakarta.persistence.CascadeType#PERSIST} * @deprecated No longer has any effect.
* operation should occur at flush time. The legacy behavior of Hibernate
* was a {@link org.hibernate.annotations.CascadeType#SAVE_UPDATE}.
*
* @return {@code true} indicates to behave in the spec-defined way
*
* @see org.hibernate.cfg.AvailableSettings#JPA_CASCADE_COMPLIANCE
*/ */
@Deprecated(since = "7.0")
boolean isJpaCascadeComplianceEnabled(); boolean isJpaCascadeComplianceEnabled();
/** /**

View File

@ -10,6 +10,10 @@
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public interface MutableJpaCompliance extends JpaCompliance { public interface MutableJpaCompliance extends JpaCompliance {
/**
* @deprecated Always enabled. See {@linkplain JpaCompliance#isJpaCascadeComplianceEnabled()}
*/
@Deprecated
void setCascadeCompliance(boolean cascadeCompliance); void setCascadeCompliance(boolean cascadeCompliance);
void setListCompliance(boolean listCompliance); void setListCompliance(boolean listCompliance);

View File

@ -12,8 +12,6 @@
* Deprecated, use {@link org.hibernate.query.TupleTransformer} * Deprecated, use {@link org.hibernate.query.TupleTransformer}
* and/or {@link org.hibernate.query.ResultListTransformer} * and/or {@link org.hibernate.query.ResultListTransformer}
* which are defined in {@link org.hibernate.query}. * which are defined in {@link org.hibernate.query}.
*
* @deprecated The contents of this package are deprecated
*/ */
@Deprecated @Deprecated
package org.hibernate.transform; package org.hibernate.transform;

View File

@ -11,9 +11,6 @@
* <p> * <p>
* Value-generation related contracts have been replaced by * Value-generation related contracts have been replaced by
* {@link org.hibernate.generator} * {@link org.hibernate.generator}
*
* @deprecated The contents of this package and its subpackages
* are deprecated
*/ */
@Remove @Deprecated @Remove @Deprecated
package org.hibernate.tuple; package org.hibernate.tuple;

View File

@ -24,7 +24,6 @@
@DomainModel(annotatedClasses = @DomainModel(annotatedClasses =
{CascadePersistSFTest.Parent.class, {CascadePersistSFTest.Parent.class,
CascadePersistSFTest.Child.class}) CascadePersistSFTest.Child.class})
@ServiceRegistry(settings = @Setting(name=JpaComplianceSettings.JPA_CASCADE_COMPLIANCE,value="true"))
public class CascadePersistSFTest { public class CascadePersistSFTest {
@Test void test(SessionFactoryScope scope) { @Test void test(SessionFactoryScope scope) {
Parent p = new Parent(); Parent p = new Parent();