orphan

Hibernate - One to many relationship and orphanRemoval cascade

北城以北 提交于 2019-12-03 13:28:57
I have a basic one to many relation parent / child like in the chapter 21 of Hibernate references book. The cascade is only from child to parent (persist cascade only because I don't want to delete the parent if I delete a child). When I add a child to the parent and I save the child, I have a TransientObjectException... @Entity public class Parent implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long id; @OneToMany(mappedBy = "parent", orphanRemoval = true) private List<Child> childs; public List<Child> getChilds() { return childs; } public void setChilds

JPA 2 / Hibernate orphan removal still not working with @OneToMany?

强颜欢笑 提交于 2019-11-30 18:08:54
I'm trying to use orphanRemoval in Hibernate 4.3.5 / JPA2 objects but it does not seem to be working as I expected. I am not sure, however, if I am doing something incorrect, or if this is still a bug in Hibernate. Given the following relationships (@Version, getters and setters omitted for brevity): @Entity public class Provider implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private Long id; private String name; @OneToMany(orphanRemoval=true,cascade=CascadeType.REMOVE) @JoinColumn(name="provider_id", referencedColumnName="id") private List

Efficiently delete orphaned m2m objects/tags in Django

妖精的绣舞 提交于 2019-11-30 15:13:35
I have two models - Photo and Tag - which are connected via a ManyToManyField. class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model): lang = models.CharField(max_length=2) name_es = models.CharField(max_length=40) name_en = models.CharField(max_length=40) Every once in a while, we get orphaned tags, that are not referenced any more by any photo. Is there an efficient way of deleting those tags? I know about this answer: Django: delete M2M orphan entries? And our solution looks like this at the moment: for tag in Tag.objects.all(): if not tag.photo_set.select

Orphans remain in database even with orphanRemoval=true on one-to-many relationship (JPA/Hibernate)

隐身守侯 提交于 2019-11-30 11:59:53
@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) @Table(name = "company_policies") @DiscriminatorColumn(name = "rule_name") public abstract class AbstractPolicyRule implements Serializable { @Transient private static final long serialVersionUID = 1L; @Id @GeneratedValue private Long id; private String value; ... } _ @Entity public class Category implements Serializable { @Transient private static final long serialVersionUID = 1L; @Id @GeneratedValue private Long id; @Column(name = "category_name") private String name; @OneToMany(fetch = FetchType.EAGER, cascade = { CascadeType.ALL

JPA 2 / Hibernate orphan removal still not working with @OneToMany?

泪湿孤枕 提交于 2019-11-30 02:13:18
问题 I'm trying to use orphanRemoval in Hibernate 4.3.5 / JPA2 objects but it does not seem to be working as I expected. I am not sure, however, if I am doing something incorrect, or if this is still a bug in Hibernate. Given the following relationships (@Version, getters and setters omitted for brevity): @Entity public class Provider implements Serializable { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name = "id") private Long id; private String name; @OneToMany(orphanRemoval

Efficiently delete orphaned m2m objects/tags in Django

十年热恋 提交于 2019-11-29 21:45:22
问题 I have two models - Photo and Tag - which are connected via a ManyToManyField. class Photo(models.Model): tags = models.ManyToManyField(Tag) class Tag(models.Model): lang = models.CharField(max_length=2) name_es = models.CharField(max_length=40) name_en = models.CharField(max_length=40) Every once in a while, we get orphaned tags, that are not referenced any more by any photo. Is there an efficient way of deleting those tags? I know about this answer: Django: delete M2M orphan entries? And

Prevent Hibernate from deleting orphaned entities while merging an entity having entity associations with orphanRemoval set to true

旧巷老猫 提交于 2019-11-29 09:07:29
Taking a very simple example of one-to-many relationship (country -> state). Country (inverse side) : @OneToMany(mappedBy = "country", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private List<StateTable> stateTableList=new ArrayList<StateTable>(0); StateTable (owning side) : @JoinColumn(name = "country_id", referencedColumnName = "country_id") @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH}) private Country country; The method attempting to update a supplied (detached) StateTable entity

Python multiprocessing and independence of children processes

旧时模样 提交于 2019-11-29 04:07:43
From the python terminal, I run some command like the following, to spawn a long-running child process: from multiprocessing.process import Process Process(target=LONG_RUNNING_FUNCTION).start() This command returns, and I can do other things in the python terminal, but anything printed by the child is still printed to my python terminal session. When I exit the terminal (either with exit or CTRL + D ), the exit command it hangs. If I hit CTRL + C during this hang, the child process is terminated. If I kill the python terminal process manually (via the posix kill command), the child process is

Setting orphanRemoval to true while migrating children from their parent to another parent

人盡茶涼 提交于 2019-11-28 12:21:33
Important Notice : If you are reading this post, then consider looking into this post too for in-depth discussions. It is a quite usual practice/situation/requirement where children of a parent may be migrated to another parent. What happens, if orphanRemoval is set to true on the inverse side of such relationships? Consider as an example, any simple one-to-many relationship as follows. Inverse side (Department) : @OneToMany(mappedBy = "department", fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private List<Employee> employeeList = new ArrayList<Employee>(0); Owning

Git Merge commits into an orphan branch

做~自己de王妃 提交于 2019-11-28 09:12:43
I'm curious to know if you CAN and if there is anything wrong with merging commits INTO my orphan branch. For this specific instance my Salesforce repository has a master branch and a pre-release branch but because our sandbox environment often has metadata that is not part of production yet we want to version control it but separate enough from our clean pre-release branch. So as it is we have the following: (Production Init Commit) (official release) / / o-------------------------o [master] \ / o------o---------o----o [pre-release] \ / o-----O [feature] \ <-- IS THIS ALLOWED/POSSIBLE/BAD