Skip to content

Commit ec556f0

Browse files
dreab8sebersole
authored andcommitted
HHH-18444 Remove deprecate Session#refresh methods
1 parent facd46f commit ec556f0

File tree

9 files changed

+10
-86
lines changed

9 files changed

+10
-86
lines changed

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -791,29 +791,6 @@ public interface Session extends SharedSessionContract, EntityManager {
791791
*/
792792
void refresh(Object object);
793793

794-
/**
795-
* Reread the state of the given managed instance associated with this session
796-
* from the underlying database. This may be useful:
797-
* <ul>
798-
* <li>when a database trigger alters the object state upon insert or update,
799-
* <li>after {@linkplain #createMutationQuery(String) executing} any HQL update
800-
* or delete statement,
801-
* <li>after {@linkplain #createNativeMutationQuery(String) executing} a native
802-
* SQL statement, or
803-
* <li>after inserting a {@link java.sql.Blob} or {@link java.sql.Clob}.
804-
* </ul>
805-
* <p>
806-
* This operation cascades to associated instances if the association is mapped
807-
* with {@link jakarta.persistence.CascadeType#REFRESH}.
808-
*
809-
* @param entityName the name of the entity
810-
* @param object a persistent instance associated with this session
811-
*
812-
* @deprecated use {@link #refresh(Object)}
813-
*/
814-
@Deprecated(since = "6.0")
815-
void refresh(String entityName, Object object);
816-
817794
/**
818795
* Reread the state of the given managed instance from the underlying database,
819796
* obtaining the given {@link LockMode}.
@@ -836,19 +813,6 @@ public interface Session extends SharedSessionContract, EntityManager {
836813
*/
837814
void refresh(Object object, LockOptions lockOptions);
838815

839-
/**
840-
* Reread the state of the given managed instance from the underlying database,
841-
* obtaining the given {@link LockMode}.
842-
*
843-
* @param entityName the name of the entity
844-
* @param object a persistent instance associated with this session
845-
* @param lockOptions contains the lock mode to use
846-
*
847-
* @deprecated use {@link #refresh(Object, LockOptions)}
848-
*/
849-
@Deprecated(since = "6.0")
850-
void refresh(String entityName, Object object, LockOptions lockOptions);
851-
852816
/**
853817
* Mark a persistence instance associated with this session for removal from
854818
* the underlying database. Ths operation cascades to associated instances if

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,6 @@ public void refresh(Object entity, RefreshOption... options) {
972972
delegate.refresh( entity, options );
973973
}
974974

975-
@Override
976-
public void refresh(String entityName, Object object) {
977-
delegate.refresh( entityName, object );
978-
}
979-
980975
@Override
981976
public void refresh(Object object, LockMode lockMode) {
982977
delegate.refresh( object, lockMode );
@@ -987,11 +982,6 @@ public void refresh(Object object, LockOptions lockOptions) {
987982
delegate.refresh( object, lockOptions );
988983
}
989984

990-
@Override
991-
public void refresh(String entityName, Object object, LockOptions lockOptions) {
992-
delegate.refresh( entityName, object, lockOptions );
993-
}
994-
995985
@Override
996986
public LockMode getCurrentLockMode(Object object) {
997987
return delegate.getCurrentLockMode( object );
@@ -1197,11 +1187,6 @@ public void persistOnFlush(String entityName, Object object, PersistContext copi
11971187
delegate.persistOnFlush( entityName, object, copiedAlready );
11981188
}
11991189

1200-
@Override
1201-
public void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException {
1202-
delegate.refresh( entityName, object, refreshedAlready );
1203-
}
1204-
12051190
@Override
12061191
public void removeOrphanBeforeUpdates(String entityName, Object child) {
12071192
delegate.removeOrphanBeforeUpdates( entityName, child );

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,6 @@ default SessionImplementor getSession() {
121121
@Deprecated
122122
void persistOnFlush(String entityName, Object object, PersistContext copiedAlready);
123123

124-
/**
125-
* @deprecated OperationalContext should cover this overload I believe
126-
*/
127-
@Deprecated
128-
void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException;
129-
130124
/**
131125
* @deprecated OperationalContext should cover this overload I believe
132126
*/

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -285,12 +285,6 @@ public void refresh(Object object) {
285285
this.lazySession.get().refresh( object );
286286
}
287287

288-
@Override
289-
@Deprecated
290-
public void refresh(String entityName, Object object) {
291-
this.lazySession.get().refresh( entityName, object );
292-
}
293-
294288
@Override
295289
public void refresh(Object object, LockMode lockMode) {
296290
this.lazySession.get().refresh( object, lockMode );
@@ -301,12 +295,6 @@ public void refresh(Object object, LockOptions lockOptions) {
301295
this.lazySession.get().refresh( object, lockOptions );
302296
}
303297

304-
@Override
305-
@Deprecated
306-
public void refresh(String entityName, Object object, LockOptions lockOptions) {
307-
this.lazySession.get().refresh( entityName, object, lockOptions );
308-
}
309-
310298
@Override
311299
public void remove(Object object) {
312300
this.lazySession.get().remove( object );

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public RefreshEvent(Object object, LockOptions lockOptions, EventSource source)
4949
}
5050
this.lockOptions = lockOptions;
5151
}
52+
53+
/**
54+
* @deprecated use {@link #RefreshEvent(Object, LockOptions, EventSource)} instead.
55+
*/
56+
@Deprecated(since = "7.0")
5257
public RefreshEvent(String entityName, Object object, LockOptions lockOptions, EventSource source){
5358
this(object,lockOptions,source);
5459
this.entityName = entityName;

hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,13 +1178,7 @@ private void fireResolveNaturalId(final ResolveNaturalIdEvent event) {
11781178
@Override
11791179
public void refresh(Object object) throws HibernateException {
11801180
checkOpen();
1181-
fireRefresh( new RefreshEvent( null, object, this ) );
1182-
}
1183-
1184-
@Override @Deprecated
1185-
public void refresh(String entityName, Object object) throws HibernateException {
1186-
checkOpen();
1187-
fireRefresh( new RefreshEvent( entityName, object, this ) );
1181+
fireRefresh( new RefreshEvent( object, this ) );
11881182
}
11891183

11901184
@Override
@@ -1196,13 +1190,7 @@ public void refresh(Object object, LockMode lockMode) throws HibernateException
11961190
@Override
11971191
public void refresh(Object object, LockOptions lockOptions) throws HibernateException {
11981192
checkOpen();
1199-
refresh( null, object, lockOptions );
1200-
}
1201-
1202-
@Override @Deprecated
1203-
public void refresh(String entityName, Object object, LockOptions lockOptions) throws HibernateException {
1204-
checkOpen();
1205-
fireRefresh( new RefreshEvent( entityName, object, lockOptions, this ) );
1193+
fireRefresh( new RefreshEvent( object, lockOptions, this ) );
12061194
}
12071195

12081196
@Override

hibernate-core/src/test/java/org/hibernate/orm/test/locking/LockModeTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,6 @@ public void testRefreshLockedEntity() {
210210
checkLockMode( a, LockMode.PESSIMISTIC_READ, session );
211211
session.refresh( a );
212212
checkLockMode( a, LockMode.PESSIMISTIC_READ, session );
213-
session.refresh( A.class.getName(), a );
214-
checkLockMode( a, LockMode.PESSIMISTIC_READ, session );
215213
session.refresh( a, Collections.emptyMap() );
216214
checkLockMode( a, LockMode.PESSIMISTIC_READ, session );
217215
session.refresh( a, null, Collections.emptyMap() );

hibernate-core/src/test/java/org/hibernate/orm/test/refresh/RefreshUsingEntityNameTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void tearDown(SessionFactoryScope scope) {
4646
public void testRefreshUsingEntityName(SessionFactoryScope scope) {
4747
scope.inSession(
4848
session ->
49-
session.refresh( "CustomName", customer )
49+
session.refresh( customer )
5050
);
5151
}
5252
}

migration-guide.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ All such cases though are already controllable by the application.
135135

136136
The effect can also often be mitigated using Hibernate's bytecode-based laziness (possibly combined with `@ConcreteProxy`).
137137

138+
* Removed `org.hibernate.Session#refresh(String entityName, Object object)` in favor of `org.hibernate.Session#refresh(Object object)`
139+
* Removed `org.hibernate.Session#refresh(String entityName, Object object, LockOptions lockOptions)` in favor of `org.hibernate.Session#refresh(Object object, LockOptions lockOptions)`
138140

139141
[[flush-persist]]
140142
== Session flush and persist

0 commit comments

Comments
 (0)