HHH-18428 Remove Session#delete
This commit is contained in:
parent
5c1ece7a84
commit
f12bb8aa12
|
@ -680,35 +680,6 @@ public interface Session extends SharedSessionContract, EntityManager {
|
|||
*/
|
||||
void persist(String entityName, Object object);
|
||||
|
||||
/**
|
||||
* Remove a persistent instance from the datastore. The argument may be
|
||||
* an instance associated with the receiving {@code Session} or a transient
|
||||
* instance with an identifier associated with existing persistent state.
|
||||
* This operation cascades to associated instances if the association is
|
||||
* mapped with {@link jakarta.persistence.CascadeType#REMOVE}.
|
||||
*
|
||||
* @param object the instance to be removed
|
||||
*
|
||||
* @deprecated use {@link #remove(Object)}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
void delete(Object object);
|
||||
|
||||
/**
|
||||
* Remove a persistent instance from the datastore. The second argument may
|
||||
* be an instance associated with the receiving {@code Session} or a transient
|
||||
* instance with an identifier associated with existing persistent state.
|
||||
* This operation cascades to associated instances if the association is
|
||||
* mapped with {@link jakarta.persistence.CascadeType#REMOVE}.
|
||||
*
|
||||
* @param entityName the entity name for the instance to be removed.
|
||||
* @param object the instance to be removed
|
||||
*
|
||||
* @deprecated use {@link #remove(Object)}
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
void delete(String entityName, Object object);
|
||||
|
||||
/**
|
||||
* Obtain the specified lock level on the given managed instance associated
|
||||
* with this session. This operation may be used to:
|
||||
|
|
|
@ -82,19 +82,6 @@ public enum CascadeType {
|
|||
*/
|
||||
LOCK,
|
||||
|
||||
/**
|
||||
* A cascade type for the {@code delete()} operation.
|
||||
* <p>
|
||||
* This is actually a synonym for {@link #REMOVE}.
|
||||
*
|
||||
* @see org.hibernate.Session#delete(Object)
|
||||
*
|
||||
* @deprecated since {@link org.hibernate.Session#delete(Object)}
|
||||
* is deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
DELETE,
|
||||
|
||||
/**
|
||||
* A cascade type for the {@code replicate()} operation.
|
||||
*
|
||||
|
|
|
@ -1009,11 +1009,7 @@ public class BinderHelper {
|
|||
case DETACH:
|
||||
cascade.append( "," ).append( "evict" );
|
||||
break;
|
||||
case DELETE:
|
||||
case REMOVE:
|
||||
if ( CascadeType.DELETE == cascadeType ) {
|
||||
warnAboutDeprecatedCascadeType( CascadeType.DELETE, CascadeType.REMOVE );
|
||||
}
|
||||
cascade.append( "," ).append( "delete" );
|
||||
break;
|
||||
case DELETE_ORPHAN:
|
||||
|
|
|
@ -922,16 +922,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
delegate.persist( entityName, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Object object) {
|
||||
delegate.delete( object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String entityName, Object object) {
|
||||
delegate.delete( entityName, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock(Object object, LockMode lockMode) {
|
||||
delegate.lock( object, lockMode );
|
||||
|
@ -1212,11 +1202,6 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
delegate.refresh( entityName, object, refreshedAlready );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) {
|
||||
delegate.delete( entityName, child, isCascadeDeleteEnabled, transientEntities );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeOrphanBeforeUpdates(String entityName, Object child) {
|
||||
delegate.removeOrphanBeforeUpdates( entityName, child );
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.hibernate.LockOptions;
|
|||
import org.hibernate.Session;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||
import org.hibernate.event.spi.DeleteContext;
|
||||
import org.hibernate.event.spi.MergeContext;
|
||||
import org.hibernate.event.spi.PersistContext;
|
||||
import org.hibernate.event.spi.RefreshContext;
|
||||
|
@ -128,12 +127,6 @@ public interface SessionImplementor extends Session, SharedSessionContractImplem
|
|||
@Deprecated
|
||||
void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException;
|
||||
|
||||
/**
|
||||
* @deprecated OperationalContext should cover this overload I believe
|
||||
*/
|
||||
@Deprecated
|
||||
void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities);
|
||||
|
||||
/**
|
||||
* @deprecated OperationalContext should cover this overload I believe
|
||||
*/
|
||||
|
|
|
@ -259,18 +259,6 @@ public class SessionLazyDelegator implements Session {
|
|||
this.lazySession.get().persist( entityName, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void delete(Object object) {
|
||||
this.lazySession.get().delete( object );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void delete(String entityName, Object object) {
|
||||
this.lazySession.get().delete( entityName, object );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void lock(Object object, LockMode lockMode) {
|
||||
this.lazySession.get().lock( object, lockMode );
|
||||
|
|
|
@ -839,18 +839,6 @@ public class SessionImpl
|
|||
|
||||
// delete() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@Override @Deprecated
|
||||
public void delete(Object object) throws HibernateException {
|
||||
checkOpen();
|
||||
fireDelete( new DeleteEvent( object, this ) );
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
public void delete(String entityName, Object object) throws HibernateException {
|
||||
checkOpen();
|
||||
fireDelete( new DeleteEvent( entityName, object, this ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
|
||||
throws HibernateException {
|
||||
|
@ -2383,9 +2371,8 @@ public class SessionImpl
|
|||
@Override
|
||||
public void remove(Object entity) {
|
||||
checkOpen();
|
||||
|
||||
try {
|
||||
delete( entity );
|
||||
fireDelete( new DeleteEvent( entity, this ) );
|
||||
}
|
||||
catch (MappingException e) {
|
||||
throw getExceptionConverter().convert( new IllegalArgumentException( e.getMessage(), e ) );
|
||||
|
|
|
@ -25,6 +25,7 @@ import jakarta.persistence.Version;
|
|||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.annotations.Cascade;
|
||||
import org.hibernate.annotations.CascadeType;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -329,7 +330,7 @@ public class NewlyInstantiatdCollectionSkipDeleteOrphanTest {
|
|||
jakarta.persistence.CascadeType.REMOVE
|
||||
}, orphanRemoval = true)
|
||||
@Cascade({
|
||||
org.hibernate.annotations.CascadeType.DELETE,
|
||||
CascadeType.REMOVE,
|
||||
org.hibernate.annotations.CascadeType.LOCK,
|
||||
org.hibernate.annotations.CascadeType.REPLICATE
|
||||
})
|
||||
|
@ -440,7 +441,7 @@ public class NewlyInstantiatdCollectionSkipDeleteOrphanTest {
|
|||
jakarta.persistence.CascadeType.REMOVE
|
||||
}, orphanRemoval = true)
|
||||
@Cascade({
|
||||
org.hibernate.annotations.CascadeType.DELETE,
|
||||
CascadeType.REMOVE,
|
||||
org.hibernate.annotations.CascadeType.LOCK,
|
||||
org.hibernate.annotations.CascadeType.REPLICATE
|
||||
})
|
||||
|
|
|
@ -80,7 +80,7 @@ public class OneToManyMappedByCascadeDeleteTest {
|
|||
@Id
|
||||
private Integer id;
|
||||
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.LAZY)
|
||||
@Cascade(CascadeType.DELETE)
|
||||
@Cascade(CascadeType.REMOVE)
|
||||
private List<Child> children = new ArrayList<>();
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -77,7 +77,7 @@ public class OneToManyMappedByOrderColumnTest {
|
|||
private Integer id;
|
||||
@OrderColumn(name = "list_idx")
|
||||
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.EAGER)
|
||||
@Cascade(CascadeType.DELETE)
|
||||
@Cascade(CascadeType.REMOVE)
|
||||
private List<Child> children = new ArrayList<>();
|
||||
|
||||
public Integer getId() {
|
||||
|
|
|
@ -90,10 +90,7 @@ public abstract class AbstractAuditWorkUnit implements AuditWorkUnit {
|
|||
|
||||
public void undo(Session session) {
|
||||
if ( isPerformed() ) {
|
||||
session.delete(
|
||||
enversService.getConfig().getAuditEntityName( getEntityName() ),
|
||||
performedData
|
||||
);
|
||||
session.remove( performedData );
|
||||
session.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,6 +149,9 @@ String isDefault();
|
|||
* Removed `org.hibernate.Session#update(Object object` and `org.hibernate.Session#update(String entityName, Object object)` in favor of `org.hibernate.Session.merge(T object)` and `org.hibernate.Session.merge(String entityName, T object)`
|
||||
* Removed `org.hibernate.annotations.CascadeType.SAVE_UPDATE` in favor of `org.hibernate.annotations.CascadeType.PERSIST` + `org.hibernate.annotations.CascadeType.MERGE`
|
||||
* Removed `@SelectBeforeUpdate`
|
||||
* Removed `org.hibernate.Session#delete(Object object)` and `org.hibernate.Session#delete(String entityName, Object object)` in favor of `org.hibernate.Session#remove(Object object)`
|
||||
* Removed `org.hibernate.annotations.CascadeType.DELETE` in favor of `org.hibernate.annotations.CascadeType#REMOVE`
|
||||
|
||||
|
||||
[WARNING]
|
||||
===
|
||||
|
|
Loading…
Reference in New Issue