Skip to content

Commit f170d56

Browse files
committed
HHH-18196 - Remove Session#save / Session#update / Session#saveOrUpdate
HHH-18428 - Remove Session#delete Javadoc fix-ups
1 parent d8c2ca7 commit f170d56

File tree

13 files changed

+23
-51
lines changed

13 files changed

+23
-51
lines changed

hibernate-core/src/main/java/org/hibernate/Interceptor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ default void onDelete(Object entity, Serializable id, Object[] state, String[] p
309309
* @throws CallbackException Thrown if the interceptor encounters any problems handling the callback.
310310
*
311311
* @see Session#remove(Object)
312-
* @see Session#delete(Object)
313312
*
314313
* @deprecated Use {@link #onRemove(Object, Object, Object[], String[], Type[])}
315314
*/

hibernate-core/src/main/java/org/hibernate/annotations/DynamicUpdate.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
* <p>
2424
*
2525
* @author Steve Ebersole
26-
*
27-
* @see SelectBeforeUpdate
2826
*/
2927
@Target( TYPE )
3028
@Retention( RUNTIME )

hibernate-core/src/main/java/org/hibernate/boot/SessionFactoryBuilder.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,10 +720,11 @@ public interface SessionFactoryBuilder {
720720
SessionFactoryBuilder enableJpaListCompliance(boolean enabled);
721721

722722
/**
723-
* @see JpaCompliance#isJpaCascadeComplianceEnabled()
723+
* @deprecated No longer has any effect.
724724
*
725-
* @see org.hibernate.cfg.AvailableSettings#JPA_CASCADE_COMPLIANCE
725+
* @see JpaCompliance#isJpaCascadeComplianceEnabled()
726726
*/
727+
@Deprecated(since = "7.0", forRemoval = true)
727728
SessionFactoryBuilder enableJpaCascadeCompliance(boolean enabled);
728729

729730
/**

hibernate-core/src/main/java/org/hibernate/cfg/JpaComplianceSettings.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,10 @@ public interface JpaComplianceSettings {
6363
String JPA_QUERY_COMPLIANCE = "hibernate.jpa.compliance.query";
6464

6565
/**
66-
* Controls whether Hibernate applies cascade
67-
* {@link jakarta.persistence.CascadeType#PERSIST} or
68-
* {@link org.hibernate.annotations.CascadeType#SAVE_UPDATE}
69-
* at flush time. If enabled, Hibernate will cascade the standard
70-
* JPA {@code PERSIST} operation. Otherwise, Hibernate will cascade
71-
* the legacy {@code SAVE_UPDATE} operation.
72-
*
73-
* @settingDefault {@link #JPA_COMPLIANCE}
74-
*
75-
* @since 6.6
66+
* @deprecated No longer has any effect. Since 7.0 (and removal of save/update processing),
67+
* Hibernate always cascades {@linkplain jakarta.persistence.CascadeType#PERSIST PERSIST}
7668
*/
69+
@Deprecated
7770
String JPA_CASCADE_COMPLIANCE = "hibernate.jpa.compliance.cascade";
7871

7972
/**

hibernate-core/src/main/java/org/hibernate/engine/spi/CascadingActions.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public String toString() {
8080
};
8181

8282
/**
83-
* @see org.hibernate.Session#delete(Object)
83+
* Used in legacy {@code Session#delete} method, which has been removed
8484
*
8585
* @deprecated Use {@link #REMOVE}
8686
*/
87-
@Deprecated(since = "6.6")
87+
@Deprecated(since = "6.6", forRemoval = true)
8888
public static final CascadingAction<DeleteContext> DELETE = REMOVE;
8989

9090
/**

hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,8 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
5353

5454
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, AbstractFlushingEventListener.class.getName() );
5555

56-
private boolean jpaBootstrap;
57-
5856
@Override
5957
public void wasJpaBootstrap(boolean wasJpaBootstrap) {
60-
this.jpaBootstrap = wasJpaBootstrap;
6158
}
6259

6360
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -205,10 +202,6 @@ protected CascadingAction<PersistContext> getCascadingAction(EventSource session
205202
return CascadingActions.PERSIST_ON_FLUSH;
206203
}
207204

208-
private static boolean isJpaCascadeComplianceEnabled(EventSource session) {
209-
return session.getSessionFactory().getSessionFactoryOptions().getJpaCompliance().isJpaCascadeComplianceEnabled();
210-
}
211-
212205
/**
213206
* Initialize the flags of the CollectionEntry, including the
214207
* dirty check.
@@ -284,14 +277,13 @@ private FlushEntityEvent createOrReuseEventInstance(
284277
EventSource source,
285278
Object key,
286279
EntityEntry entry) {
287-
final FlushEntityEvent entityEvent = possiblyValidExistingInstance;
288-
if ( entityEvent == null || !entityEvent.isAllowedToReuse() ) {
280+
if ( possiblyValidExistingInstance == null || !possiblyValidExistingInstance.isAllowedToReuse() ) {
289281
//need to create a new instance
290282
return new FlushEntityEvent( source, key, entry );
291283
}
292284
else {
293-
entityEvent.resetAndReuseEventInstance( key, entry );
294-
return entityEvent;
285+
possiblyValidExistingInstance.resetAndReuseEventInstance( key, entry );
286+
return possiblyValidExistingInstance;
295287
}
296288
}
297289

hibernate-core/src/main/java/org/hibernate/event/spi/DeleteContext.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,15 @@
88

99
import java.util.IdentityHashMap;
1010

11+
import org.hibernate.event.internal.DefaultDeleteEventListener;
12+
1113
/**
12-
* A {@link DeleteEvent} represents a {@linkplain org.hibernate.Session#delete(Object) delete operation}
14+
* A {@link DeleteEvent} represents a {@linkplain org.hibernate.Session#remove delete operation}
1315
* applied to a single entity. A {@code DeleteContext} is propagated across all cascaded delete operations,
1416
* and keeps track of all the entities we've already visited.
1517
*
18+
* @see DefaultDeleteEventListener#onDelete(DeleteEvent, DeleteContext)
19+
*
1620
* @author Gavin King
1721
*/
1822
public interface DeleteContext {

hibernate-core/src/main/java/org/hibernate/jpa/internal/MutableJpaComplianceImpl.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
2626
private boolean closedCompliance;
2727
private boolean cachingCompliance;
2828
private boolean loadByIdCompliance;
29-
private boolean cascadeCompliance;
3029

3130
public MutableJpaComplianceImpl(Map<?,?> configurationSettings) {
3231
this(
@@ -39,11 +38,6 @@ public MutableJpaComplianceImpl(Map<?,?> configurationSettings) {
3938
public MutableJpaComplianceImpl(Map<?,?> configurationSettings, boolean jpaByDefault) {
4039
final Object legacyQueryCompliance = configurationSettings.get( AvailableSettings.JPAQL_STRICT_COMPLIANCE );
4140

42-
cascadeCompliance = ConfigurationHelper.getBoolean(
43-
AvailableSettings.JPA_CASCADE_COMPLIANCE,
44-
configurationSettings,
45-
jpaByDefault
46-
);
4741
//noinspection deprecation
4842
listCompliance = ConfigurationHelper.getBoolean(
4943
AvailableSettings.JPA_LIST_COMPLIANCE,
@@ -103,7 +97,7 @@ public boolean isJpaTransactionComplianceEnabled() {
10397
}
10498

10599
public boolean isJpaCascadeComplianceEnabled() {
106-
return cascadeCompliance;
100+
return true;
107101
}
108102

109103
@Override
@@ -151,7 +145,6 @@ public void setListCompliance(boolean listCompliance) {
151145

152146
@Override
153147
public void setCascadeCompliance(boolean cascadeCompliance) {
154-
this.cascadeCompliance = cascadeCompliance;
155148
}
156149

157150
@Override
@@ -197,7 +190,6 @@ public void setLoadByIdCompliance(boolean enabled) {
197190
public JpaCompliance immutableCopy() {
198191
JpaComplianceImpl.JpaComplianceBuilder builder = new JpaComplianceImpl.JpaComplianceBuilder();
199192
builder = builder.setListCompliance( listCompliance )
200-
.setCascadeCompliance( cascadeCompliance )
201193
.setProxyCompliance( proxyCompliance )
202194
.setOrderByMappingCompliance( orderByMappingCompliance )
203195
.setGlobalGeneratorNameCompliance( generatorNameScopeCompliance )

hibernate-core/src/main/java/org/hibernate/jpa/spi/JpaCompliance.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,9 @@ public interface JpaCompliance {
8181
boolean isJpaClosedComplianceEnabled();
8282

8383
/**
84-
* JPA specifies that a {@link jakarta.persistence.CascadeType#PERSIST}
85-
* operation should occur at flush time. The legacy behavior of Hibernate
86-
* was a {@link org.hibernate.annotations.CascadeType#SAVE_UPDATE}.
87-
*
88-
* @return {@code true} indicates to behave in the spec-defined way
89-
*
90-
* @see org.hibernate.cfg.AvailableSettings#JPA_CASCADE_COMPLIANCE
84+
* @deprecated No longer has any effect.
9185
*/
86+
@Deprecated(since = "7.0")
9287
boolean isJpaCascadeComplianceEnabled();
9388

9489
/**

hibernate-core/src/main/java/org/hibernate/jpa/spi/MutableJpaCompliance.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* @author Steve Ebersole
1111
*/
1212
public interface MutableJpaCompliance extends JpaCompliance {
13+
/**
14+
* @deprecated Always enabled. See {@linkplain JpaCompliance#isJpaCascadeComplianceEnabled()}
15+
*/
16+
@Deprecated
1317
void setCascadeCompliance(boolean cascadeCompliance);
1418

1519
void setListCompliance(boolean listCompliance);

0 commit comments

Comments
 (0)