Questions tagged [hibernate-cascade]
87 questions
1
vote
0 answers
Hibernate3 many to many cascade deleting with cleanup
I have a problem with cascade deleting in Hibernate 3.6. I have the following many to many relationship between two entity classes: Menu and Item. Note that this is a uni-directional relationship. A Menu instance has a reference the set of Items it…

user3278928
- 11
- 1
1
vote
0 answers
Hibernate cascading merge with non-persistent objects
I have the following structure in my project:
public class A {
@Cascade({org.hibernate.annotations.CascadeType.SAVE_UPDATE, org.hibernate.annotations.CascadeType.PERSIST,
org.hibernate.annotations.CascadeType.REFRESH,…

Tobb
- 11,850
- 6
- 52
- 77
0
votes
1 answer
hibernate NonUniqueObjectException when save update
I have this simple situation:
@Entity
public class Customer{
@ManyToMany(fetch=FetchType.EAGER)
@Cascade(CascadeType.SAVE_UPDATE)
private List products=new ArrayList();
}
@Entity
public class Produtc{
…

blow
- 12,811
- 24
- 75
- 112
0
votes
1 answer
How to save only a child entity and populate the parentId in the table Using save operation on the child entity
I would like to understand this basic concept. How do we save the child entity and populate the foreign Key ID in the Child table. I have this situation where Parent Can have many child. But the Child can only have one Parent.
`
Entity
@Table(name =…
0
votes
0 answers
How to choose the right cascade types for entity relationshships following best practices: JPA
I have been working on Spring Boot and JPA for quite some time and this question is raised several times. How should one decide to choose the right cascade types for entity relationships?
A scenario-
I have 2 entities-
User and Category. Now, I want…

ayush
- 464
- 5
- 17
0
votes
1 answer
Why OneToMany relationship update needs only Many side to be saved without cascade configured?
I'm trying to understand why a correct behaviour is happening:
I'm working with Hibernate 5.6 and I have a OneToMany bidirectional relationship.
All the following is happening in a transaction:
I recover with session.get an object which already…

Mary
- 43
- 5
0
votes
1 answer
How to cascade if child entity is not inserted, else no cascading
We are currently using seam framework. And we have a little trouble with annotating entities. We have a Deal entity that has a Tag entity child. We annotated entities as following;
@Entity
public class Deal implements Serializable {
…

Çağdaş
- 993
- 1
- 12
- 33
0
votes
0 answers
Inherit property from parent class and add attribute to the inherited annotation
I have a derived class MyBusinessBody which extends a parent class BusinessBody.
One field in BusinessBody looks like:
public class BusinessBody{
@OneToOne(fetch = FetchType.LAZY)
private Trade trade;
//setter and getter
...
}
Now, I want…

J.E.Y
- 1,173
- 2
- 15
- 37
0
votes
1 answer
JPA Composite Keys and Cascade
I'd like to use JPA CASCADE to Persist parent and its children at the same time. The parent class (Filter) has a composite key (PKFilter). Aldo, the children class (FilterRule) has its composite key (PKFilterRule). The primary key classes are…

regisxp
- 956
- 2
- 10
- 31
0
votes
1 answer
moving an entity into another owned OneToMany Collection
In my application, there is a Person entity that has numerous roles of type PersonRole.
@Entity
public class Person {
@OneToMany(mappedBy = "person",
cascade=CascadeType.ALL,
orphanRemoval=true,
…

EasterBunnyBugSmasher
- 1,507
- 2
- 15
- 34
0
votes
1 answer
Hibernate OneToOne Relationship remove child entity causes to remove whole parent entity row
I've the following problem with my application.
Definition:
I have 3 tables. User, Password and Confirmation Token. User table is the parent table. Password and confirmation token tables are the children tables that have one to one relationship with…

Ahmet Eroğlu
- 594
- 1
- 7
- 23
0
votes
0 answers
One to Many cascade All - save children and dependents
I have 3 entities as below:
@Entity
@Table(name = "person", schema = "test")
public class Person implements Persistable
{
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "***")
@SequenceGenerator(name = "***",…

Divyesh Kalbhor
- 385
- 3
- 19
0
votes
0 answers
Spring boot application using Set<> persistentSet exception
i am having issues while trying to get Set<> Collection from the DataBase.
this is the relevant part of the code:
@Entity
public Class User {
...
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private Set…

user3469465
- 39
- 7
0
votes
1 answer
hibernate cascading delete with multiple levels
sadly I couldn't find a solution for my current problem. (Please post a link if i missed something)
I have a multiple layer entity structure as following
class Parent {
@OneToMany(
mappedBy = "parent",
cascade =…

ChrizzleWhizzle
- 157
- 8
0
votes
0 answers
Hibernate is not creating new child entities while updating existing parent entity
I have a One to Many cardinality relationship like the following -
@Entity
@Table(name = "PARENT_TABLE")
public class Parent {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
…

Vivek Vardhan
- 1,118
- 3
- 21
- 44