# @ManyToOne without cascade REMOVE

**URL:** <https://discourse.hibernate.org/t/manytoone-without-cascade-remove/8811>\
**Category:** Hibernate ORM\
**Created:** [January 8, 2024, 10:17am UTC](https://discourse.hibernate.org/t/manytoone-without-cascade-remove/8811 "2024-01-08T10:17:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [January 8, 2024, 10:17am UTC](https://discourse.hibernate.org/t/manytoone-without-cascade-remove/8811/1 "2024-01-08T10:17:09Z")

</div>

Hi,

To confirm the solution:

I have a scenario where I have a @OneToMany relationship (on object `Partenaire`) without the REMOVE cascade linked with @ManyToOne (on object `ConventionPartenaire`).

When I delete object `Partenaire`, it then tells me that it’s not possible to save object `ConventionPartenaire` because it holds a transient object (which is normal).

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/hibernate/original/2X/b/bc4689f3e7f5ee9b8ef3fd50672f1a52276b62d8.png)

Is the solution to set the return variable to null by removing the association from `ConventionPartenaire` to `Partenaire` (`@PreRemove`) ?

Thank you !

```auto
@Entity
public class Partenaire {
  @OneToMany(mappedBy = "partenaire", fetch = EAGER, cascade = {REFRESH, PERSIST})
  private Set<ConventionPartenaire> conventions = new HashSet<>();

  @PreRemove
  public void preRemove() {
    conventions.forEach(this::removeFromConventions);
  }

  public boolean removeFromConventions(ConventionPartenaire conventionPartenaire) {
    conventionPartenaire.setPartenaire(null);
    return conventions.remove(conventionPartenaire);
  }
}

@Entity
public class ConventionPartenaire {
  @ManyToOne
  private Partenaire partenaire;
}

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [January 8, 2024, 2:38pm UTC](https://discourse.hibernate.org/t/manytoone-without-cascade-remove/8811/2 "2024-01-08T14:38:48Z")

</div>

Yeah, that looks ok to me.
