Questions tagged [hibernate-cascade]
87 questions
0
votes
1 answer
How to cascade delete unidirectional
I have a case where I have a user and the user had an EmailVerificationToken.
I would like to delete the EmailVerificationToken when the user gets deleted.
However, since the EmailVerificationToken is an object that is only needed for a short period…

yasgur99
- 756
- 2
- 11
- 32
0
votes
0 answers
Delete parent row without affecting child rows in hibernate
I have a problem with my code in @Manytomany hibernate relationship.
I see above issue is due to "CascadeType.ALL" on @ManyToMany relationship side. But if i remove this CascadeType.ALL in @ManyToMany. If I change this CascadeType.ALL in @ManyToMany…

Nhu Pham
- 23
- 4
0
votes
1 answer
Using Spring Data JPA - how to save ONLY UNIQUE items in child entity while saving parent entity and using CascadeType=PERSIST
I am preparing simple Spring app. I have 2 entities :
Book.class (parent) and Author.class (child): with @OneToMany from Author view and @ManyToOne(cascade=CascadeType.PERSIST) from Book view relations. While saving new Book - also Author is being…

pastapola
- 1
- 1
- 3
0
votes
1 answer
Cascade behaviour for persist() when creating a new entity vs modifying an existing entity
I am trying to understand why the behaviour of persist() is different on a ManyToOne in the cases of first, persisting a new entity and second, modifying that entity.
My test setup has Employee having a unidirectional ManyToOne with Department;…

JL_SO
- 1,742
- 1
- 25
- 38
0
votes
1 answer
Different Persistance Behaviour with In-Memory and MySQL DB
I have a parent entity and a child entity with a one to many relationship.
When using @DataJpaTest (i.e. configuring an in memory database), the following works as expected:
LOG.info("Creating stops");
Stop stop1 = new Stop(new Time(0), "Acton…

Jordan Mackie
- 2,264
- 4
- 25
- 45
0
votes
0 answers
Spring Data JPA. Hibernate 5. Conditional ManyToMany cascade handling
There are a lot of information and examples how to use @ManyToMany and this part is clear in general. I have not found elegant solution for my case. I know how to use work around, but I hope anyone knows and can share elegant solution or idea which…

Sergii
- 7,044
- 14
- 58
- 116
0
votes
2 answers
Refresh one-to-many relationship after child was added
So I have two entities:
Person.java
@Entity
@Table(name = "persons")
public class Person {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
@OneToMany(mappedBy="person", cascade = CascadeType.REMOVE)
…

wwwww
- 339
- 3
- 15
0
votes
2 answers
Hibernate one to one mapping. Delete row from dependent table
Tables : Student, Address
Student.ADDR_ID column maps to Address.ID
Annotation in my Student class is as follows
public class Student {
String name, surname;
int rollNumber;
Teacher classTeacher;
Address…

Kaushik Lele
- 6,439
- 13
- 50
- 76
0
votes
4 answers
Can't get cascade save nor delete on embedded class ref to work
I've created two simple Grails V3 domain classes where location is embedded attribute type in parent Venue like this
import java.time.LocalDate
class Venue {
String name
LocalDate dateCreated
LocalDate lastVisited
LocalDate…

WILLIAM WOODMAN
- 1,185
- 5
- 19
- 36
0
votes
1 answer
Hibernate Cascade another Id from another database
For Example, I have class A with cascade to B:
public class A{
private String id;
private Set bs = new HashSet(0);
@Id
@GenericGenerator(name = "seq_id", strategy = generators.SequenceIdGenerator")
…

triForce420
- 719
- 12
- 31
0
votes
1 answer
@OneToOne - Cascade all not saving the parent Id
guys ! I have problem with saving on the "child" table parent's id When persist the child object, the column with parent id is null..
Parent ( User class)
import javax.persistence.Column;
import javax.persistence.Entity;
import…

FBMtrader Fbmtrader
- 13
- 6
0
votes
0 answers
JPA entitiy hierarchy merge results in "Multiple representations of the same entity" exception
I have an entity hierarchy, which is represented and editable in a web interface and persisted in the data layer of my web application. To make persisting easier I annotated some entities with CascadaType.PERSIST and CascadeType.MERGE - but this…

raho
- 129
- 4
- 18
0
votes
2 answers
Hibernate ConstraintViolationException on delete
I have 2 entities which are Geofence and Device, once the user assign one geofence to some device there will be an association created represented by GeofenceDevice entity.
The problem is that once I want to delete a GeofenceDevice object I get an…

Ghassen Khalil ATI
- 201
- 4
- 13
0
votes
1 answer
Ask Hibernate to not perform the cascade when using a join table?
When I delete a record from table r, it in turn deletes a record from a linking table b because r has a Many-To-Many relationship with b and I am using Hibernate Join Table to associate them. Here is where my problem comes: I have a view that relies…

shiningcartoonist
- 187
- 1
- 6
0
votes
0 answers
JPA cascade none does not work
Scenario:
`
@Entity
@Table(name = "a")
@AttributeOverride(name = "id", column = @Column(name = "a_id"))
public class A {
private ...
private List<> ....
}`
`
@Entity
@Table(name = "b")
@AttributeOverride(name = "id", column = @Column(name =…

bluelabel
- 1,996
- 6
- 29
- 44