mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-17 16:44:57 +00:00
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);
|
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
|
* Obtain the specified lock level on the given managed instance associated
|
||||||
* with this session. This operation may be used to:
|
* with this session. This operation may be used to:
|
||||||
|
@ -82,19 +82,6 @@ public enum CascadeType {
|
|||||||
*/
|
*/
|
||||||
LOCK,
|
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.
|
* A cascade type for the {@code replicate()} operation.
|
||||||
*
|
*
|
||||||
|
@ -1009,11 +1009,7 @@ private static String renderCascadeTypeList(EnumSet<CascadeType> cascadeTypes) {
|
|||||||
case DETACH:
|
case DETACH:
|
||||||
cascade.append( "," ).append( "evict" );
|
cascade.append( "," ).append( "evict" );
|
||||||
break;
|
break;
|
||||||
case DELETE:
|
|
||||||
case REMOVE:
|
case REMOVE:
|
||||||
if ( CascadeType.DELETE == cascadeType ) {
|
|
||||||
warnAboutDeprecatedCascadeType( CascadeType.DELETE, CascadeType.REMOVE );
|
|
||||||
}
|
|
||||||
cascade.append( "," ).append( "delete" );
|
cascade.append( "," ).append( "delete" );
|
||||||
break;
|
break;
|
||||||
case DELETE_ORPHAN:
|
case DELETE_ORPHAN:
|
||||||
|
@ -922,16 +922,6 @@ public void persist(String entityName, Object object) {
|
|||||||
delegate.persist( entityName, object );
|
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
|
@Override
|
||||||
public void lock(Object object, LockMode lockMode) {
|
public void lock(Object object, LockMode lockMode) {
|
||||||
delegate.lock( object, lockMode );
|
delegate.lock( object, lockMode );
|
||||||
@ -1212,11 +1202,6 @@ public void refresh(String entityName, Object object, RefreshContext refreshedAl
|
|||||||
delegate.refresh( entityName, object, refreshedAlready );
|
delegate.refresh( entityName, object, refreshedAlready );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void delete(String entityName, Object child, boolean isCascadeDeleteEnabled, DeleteContext transientEntities) {
|
|
||||||
delegate.delete( entityName, child, isCascadeDeleteEnabled, transientEntities );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeOrphanBeforeUpdates(String entityName, Object child) {
|
public void removeOrphanBeforeUpdates(String entityName, Object child) {
|
||||||
delegate.removeOrphanBeforeUpdates( entityName, child );
|
delegate.removeOrphanBeforeUpdates( entityName, child );
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||||
import org.hibernate.event.spi.DeleteContext;
|
|
||||||
import org.hibernate.event.spi.MergeContext;
|
import org.hibernate.event.spi.MergeContext;
|
||||||
import org.hibernate.event.spi.PersistContext;
|
import org.hibernate.event.spi.PersistContext;
|
||||||
import org.hibernate.event.spi.RefreshContext;
|
import org.hibernate.event.spi.RefreshContext;
|
||||||
@ -128,12 +127,6 @@ default SessionImplementor getSession() {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
void refresh(String entityName, Object object, RefreshContext refreshedAlready) throws HibernateException;
|
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
|
* @deprecated OperationalContext should cover this overload I believe
|
||||||
*/
|
*/
|
||||||
|
@ -259,18 +259,6 @@ public void persist(String entityName, Object object) {
|
|||||||
this.lazySession.get().persist( entityName, object );
|
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
|
@Override
|
||||||
public void lock(Object object, LockMode lockMode) {
|
public void lock(Object object, LockMode lockMode) {
|
||||||
this.lazySession.get().lock( object, lockMode );
|
this.lazySession.get().lock( object, lockMode );
|
||||||
|
@ -839,18 +839,6 @@ private void fireMerge(final MergeContext mergeContext, final MergeEvent event)
|
|||||||
|
|
||||||
// delete() operations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// 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
|
@Override
|
||||||
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
|
public void delete(String entityName, Object object, boolean isCascadeDeleteEnabled, DeleteContext transientEntities)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
@ -2383,9 +2371,8 @@ public SessionImplementor getSession() {
|
|||||||
@Override
|
@Override
|
||||||
public void remove(Object entity) {
|
public void remove(Object entity) {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
delete( entity );
|
fireDelete( new DeleteEvent( entity, this ) );
|
||||||
}
|
}
|
||||||
catch (MappingException e) {
|
catch (MappingException e) {
|
||||||
throw getExceptionConverter().convert( new IllegalArgumentException( e.getMessage(), e ) );
|
throw getExceptionConverter().convert( new IllegalArgumentException( e.getMessage(), e ) );
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
import org.hibernate.FlushMode;
|
import org.hibernate.FlushMode;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.annotations.Cascade;
|
import org.hibernate.annotations.Cascade;
|
||||||
|
import org.hibernate.annotations.CascadeType;
|
||||||
import org.hibernate.annotations.DynamicUpdate;
|
import org.hibernate.annotations.DynamicUpdate;
|
||||||
|
|
||||||
import org.hibernate.testing.TestForIssue;
|
import org.hibernate.testing.TestForIssue;
|
||||||
@ -329,7 +330,7 @@ public void setName(String name) {
|
|||||||
jakarta.persistence.CascadeType.REMOVE
|
jakarta.persistence.CascadeType.REMOVE
|
||||||
}, orphanRemoval = true)
|
}, orphanRemoval = true)
|
||||||
@Cascade({
|
@Cascade({
|
||||||
org.hibernate.annotations.CascadeType.DELETE,
|
CascadeType.REMOVE,
|
||||||
org.hibernate.annotations.CascadeType.LOCK,
|
org.hibernate.annotations.CascadeType.LOCK,
|
||||||
org.hibernate.annotations.CascadeType.REPLICATE
|
org.hibernate.annotations.CascadeType.REPLICATE
|
||||||
})
|
})
|
||||||
@ -440,7 +441,7 @@ public void setVersion(Long version) {
|
|||||||
jakarta.persistence.CascadeType.REMOVE
|
jakarta.persistence.CascadeType.REMOVE
|
||||||
}, orphanRemoval = true)
|
}, orphanRemoval = true)
|
||||||
@Cascade({
|
@Cascade({
|
||||||
org.hibernate.annotations.CascadeType.DELETE,
|
CascadeType.REMOVE,
|
||||||
org.hibernate.annotations.CascadeType.LOCK,
|
org.hibernate.annotations.CascadeType.LOCK,
|
||||||
org.hibernate.annotations.CascadeType.REPLICATE
|
org.hibernate.annotations.CascadeType.REPLICATE
|
||||||
})
|
})
|
||||||
|
@ -80,7 +80,7 @@ public static class Parent {
|
|||||||
@Id
|
@Id
|
||||||
private Integer id;
|
private Integer id;
|
||||||
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.LAZY)
|
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.LAZY)
|
||||||
@Cascade(CascadeType.DELETE)
|
@Cascade(CascadeType.REMOVE)
|
||||||
private List<Child> children = new ArrayList<>();
|
private List<Child> children = new ArrayList<>();
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
@ -77,7 +77,7 @@ public static class Parent {
|
|||||||
private Integer id;
|
private Integer id;
|
||||||
@OrderColumn(name = "list_idx")
|
@OrderColumn(name = "list_idx")
|
||||||
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.EAGER)
|
@OneToMany(targetEntity = Child.class, mappedBy = "parent", fetch = FetchType.EAGER)
|
||||||
@Cascade(CascadeType.DELETE)
|
@Cascade(CascadeType.REMOVE)
|
||||||
private List<Child> children = new ArrayList<>();
|
private List<Child> children = new ArrayList<>();
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
@ -90,10 +90,7 @@ protected void setPerformed(Object performedData) {
|
|||||||
|
|
||||||
public void undo(Session session) {
|
public void undo(Session session) {
|
||||||
if ( isPerformed() ) {
|
if ( isPerformed() ) {
|
||||||
session.delete(
|
session.remove( performedData );
|
||||||
enversService.getConfig().getAuditEntityName( getEntityName() ),
|
|
||||||
performedData
|
|
||||||
);
|
|
||||||
session.flush();
|
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.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 `org.hibernate.annotations.CascadeType.SAVE_UPDATE` in favor of `org.hibernate.annotations.CascadeType.PERSIST` + `org.hibernate.annotations.CascadeType.MERGE`
|
||||||
* Removed `@SelectBeforeUpdate`
|
* 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]
|
[WARNING]
|
||||||
===
|
===
|
||||||
|
Loading…
x
Reference in New Issue
Block a user