Questions tagged [all-delete-orphan]
26 questions
7
votes
2 answers
Delete orphaned records in postgres. Delete using join. Performance
I have a case where I need to cleanup table from orphans regularly, so I'm looking for a high performance solution. I tried using 'IN' clause, but its not really fast. Columns have all the required indexes in both tables.(id - primary key,…

admix
- 1,752
- 3
- 22
- 27
6
votes
1 answer
Annotation for all-delete-orphan in hibernate 4.1.4
I'm new to this hibernate annotation. I want to convert this xml mapping into annotations:

Shailu
- 163
- 1
- 5
- 16
4
votes
1 answer
Hibernate - proper way to update collection which is mapped with cascading type all-delete-orphan
What would be the right and easy way to update the collection if it's mapped with all-delete-orphan by it's "parent" object?
By updating I don't mean just adding/removing items from collection, but also updating the values of item properties (of…

Josip Maslac
- 270
- 3
- 8
3
votes
0 answers
Is Hibernate @Cascade(CascadeType.DELETE_ORPHAN) correct when it's applied to @ManyToOne?
Let's imagine the scenario: Entity Company and Entity Address has one-to-many bidirectional relationship. So Entity Address will look like:
@Entity
@Table(name = "address")
public class AddressHbm{
@Id
@GeneratedValue(generator =…

macemers
- 2,194
- 6
- 38
- 55
2
votes
0 answers
Orphan removal with @Where clause
I have a hierarchical structure. Some children are hidden so I have @Where clause:
@OneToMany(fetch = FetchType.LAZY, orphanRemoval = true)
@org.hibernate.annotations.Where(clause = "hidden=false")
private List children;
But when I want to…

piotrek
- 13,982
- 13
- 79
- 165
2
votes
2 answers
Using orphan removal in Hibernate
I am working in Spring-Hibernate application.My question is related to orphan removal as described below in the code.
@Entity
public class User {
...........
@OneToMany(mappedBy = "user", orphanRemoval = true, cascade = CascadeType.ALL)
…

Anand
- 20,708
- 48
- 131
- 198
2
votes
1 answer
FluentNHibernate not deleting child entity even with AllDeleteOrphan
I have a Car entity which possesses doors. When the car is deleted, the doors should be deleted too because they don't make sense on their own.
Here's the mapping in FluentNHibernate.
public class CarMap : ClassMap
{
public CarMap()
{
…

pobed2
- 359
- 2
- 9
2
votes
1 answer
Hibernate cascade delete orphan
I have 2 entities: News and NewsComment
@Entity
@Table(name = "news", schema = "city")
public class News {
private Set comments = new HashSet();
...
…

user1480528
- 37
- 2
- 8
1
vote
2 answers
orphanRemoval causes error with lazy loaded collection
I use hibernate 5.0.8 and spring data jpa 1.10.1
Given these entities
class Model {
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH})
@JoinColumn(nullable = false)
private…

Harald
- 33
- 4
1
vote
0 answers
Getting constraint violation exception on deleting parent although i used cascadeType.all
As per my requirement I have two entities company and contact which are associated with @onetomany mapping and I want to delete the company and its related contacts with it.
I have used the Cascade.All but still I am getting the constraint violation…

user3852293
- 11
- 3
1
vote
0 answers
How can I detect when instances are deleted via a "delete-orphan" cascade?
I'm trying to add audit logging for some of my tables, which I've implemented in an after_flush listener. By accessing the session state in session.new/dirty/deleted, I can get the information I need.
Well, at least for most cases: I'm having no…

nfelger
- 823
- 9
- 21
1
vote
1 answer
NHibernate Many-To-Many all-delete-orphans
I have got two entities: Document and File connected in Many-To-Many relationship.
I want them to behave as follows:
Document has many files.
Files can belong to many documents at the same time.
When I delete document, each file should be deleted…

Kuba Matjanowski
- 350
- 3
- 14
1
vote
1 answer
Fluent NHibernate reference / many-to-one mapping cascade all not working
I have some problem with cascade all (orphan) and delete the old objcet from the database.
Example:
I have an class A which contains an object of class B. Now, when I create an object of class A and save it, everything works fine. When I call the…

user3215952
- 223
- 5
- 11
1
vote
1 answer
Grails fails to delete orphan on collection in Unit tests, if composite id is used
I am using Grails 2.4.4. I would like to test
the persistence in Unit Test Class with an in-memory database.
I have a Parent class with a oneToMany relation with Child. The Child is ownedBy the Parent and has a composite key involving the parent.…

Andrea
- 335
- 3
- 12
0
votes
1 answer
Hibernate mapping: delete-orphan cascade
Question about hibernate and delete-orphan cascade. Suppose I have some Parent class with collection of Child inside it. In hibernate mapping for Parent class
for one-to-many relation I set cascade all-delete-orphan. Suppose that all the rest is…

sasha123
- 21
- 5