Questions tagged [hibernate-cascade]
87 questions
2
votes
0 answers
Hibernate CascadeType.Persist creates a select query
I am trying to persist an object which has one to many relation with other entity. Using CascadeType.ALL works but, indeed I do not want to delete that entity when I delete main object. Therefore I tried to use CascadeType.PERSIST. But when I use it…

user1474111
- 1,356
- 3
- 23
- 47
2
votes
1 answer
Cascade delete on entity with @ElementCollection
I have a problem when cascade deleting my Parent entity:
org.postgresql.util.PSQLException: UPDATE or DELETE on table "child" violates constraint "XXX": for key (id)=(4) there are references in table "child_properties"
@Entity
@Table(name =…

Kampaii
- 123
- 2
- 11
2
votes
1 answer
Hibernate: Problem with cascade delete for one to many relation
I have following entity model.
@Entity
@Table(name="product")
public class ProductEntity {
@Id
@GeneratedValue(generator = "uuid2")
@GenericGenerator(name = "uuid2", strategy = "uuid2")
private UUID id;
...
…

Dima Stoyanov
- 121
- 1
- 11
2
votes
2 answers
Hibernate: How to insert OnetoMany children by cascade
I am trying persist a new 'UserTopics' object and map the newly UserTopic in the 'Topic' table corresponded to multiple userId's.
I've no idea what I am doing wrong here. Below is the code I have and the exception.
My UserTopics…

user2342259
- 345
- 2
- 9
- 27
2
votes
2 answers
Prevent delete from cascading to an entity instance
Consider the following JPA entities:
@Entity @Table(name = "product") class Product { ... }
@Entity @Table(name = "stock") class Stock {
@JoinColumn(name = "product_id", updatable = false)
@ManyToOne(fetch = FetchType.LAZY)
private Product…

manish
- 19,695
- 5
- 67
- 91
2
votes
1 answer
Hibernate cascade many to many creates duplicates in child reference
Ok so I'm new to hibernate.
The question is about cascade many-to-many, avoiding to add duplicate values.
So I follow this example.
tutorialspoint hibernate many to many mapping
The problem is this, that if I run program twice it adds duplicate…

K.I.
- 759
- 1
- 11
- 30
2
votes
2 answers
How to setup update on cascade in hibernate 4 with javax.persistence.OneToMany?
I use hibernate 4.2.
It doesn't give me hibernate variant of OneToMany annotation, but only javax.persistence.OneToMany.
So I use it as
public class Parent {
...........
@OneToMany(mappedBy = "parent", fetch = FetchType.LAZY, cascade =…

Volodymyr Levytskyi
- 3,364
- 9
- 46
- 83
2
votes
1 answer
Delete one-to-one: Hibernate 3 + Spring 3 + PostgreSQL 9.1
This is my first post and I am new to Hibernate + Spring. I am using XML for Hibernate mapping declaration in my applicationContext.xml file.
Briefly, I am trying to do:
parent.setChild(null);
parentDao.update(parent);
With the hope that it will…

Jdaydai
- 101
- 1
- 8
2
votes
1 answer
Hibernate deletes record from many-to-many association table after updating
In my teamwork oriented app I have many-to-many relationship between User and Team, so hibernate creates association table. Problem is, that after updating the User which has Team, hibernate deletes corresponding association record from USER_TEAM…

paul.cook
- 39
- 1
- 5
2
votes
1 answer
Issue in deleting a child object in Hibernate "deleted object would be re-saved by cascade"
I have the following two entities:
1- Deal
@OneToMany(cascade=CascadeType.ALL,mappedBy = "deal", fetch = FetchType.EAGER)
@Fetch( FetchMode.SELECT)
private List dealCheckList;
2- DealCheckList
@JoinColumn(name = "DEAL_ID",…

Anand
- 20,708
- 48
- 131
- 198
1
vote
2 answers
Hibernate, unidirectional ManyToOne and the desire for a "On Delete Cascade" Feature
I have a problem that's equal to the one presented here: how to define an inverse cascade delete on a many-to-one mapping in hibernate
After searching for a while I can't find a decent/clean solution for this. I can't have the parent entity have an…

Caesar Ralf
- 2,203
- 1
- 18
- 36
1
vote
1 answer
Using cascades with mappedBy in Hibernate
I have two classes teacher and course. teacher can have multiple courses. I want to use all cascades except Remove.
public Teacher {
@OneToMany(mappedBy = "teacher",cascade =…

teoberk
- 11
- 2
1
vote
1 answer
deleted object would be re-saved by cascade (remove deleted object from associations) : Error while trying to attach a child from one parent to other
In an application using hibernate 5.0.9 have nested parent child relation where parent is relation owner respresented as below.
Tables: -
ParentEntity
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(name =…

shivani
- 11
- 1
1
vote
1 answer
Two problems in a @OneToOne relationship
I am using Hibernate 4.3.6.Final, and WildFly 16. I have two problems with a @OneToOne relationship.
1.) First problem: Unknown mappedBy in: at.home.digest.model.Expose.home, referenced property unknown: at.home.digest.model.Home.expose"}}
These are…

Alex Mi
- 1,409
- 2
- 21
- 35
1
vote
0 answers
How to disable delete cascading for JPA joined inheriting Entity?
I have three entities. Both ResolvedCorpus and UnqualifiedCorpus are subclasses of Corpus to help model and address certain concerns for some Corpus.
Joined inheritance type is selected for data persistence via JPA.
The entities are defined as…

glenlivet1986
- 260
- 3
- 12