java - Hibernate - How to cascade deletes using annotations where only unidirectional child relationship is specified -


I believe that I have two bodies, one original object and one child, I want the child to be the parent unit and There should be a specific relationship for a reference, but I do not want parents to be aware of it. The reason for this is that there are many such relationships and clearly specifying the relationship for all these children, it means that continuous updating and polluting the parent's items. Although I still want to tame the child of the parent's object In the form of an additional constraint, only the child references the ID of the parent near the object, which is a reference set by the set parent unit. I believe there is something like this:

@Antie class child {@Id @ generatedValue (strategy = GenerationType.AUTO) Private Long ID; @column (drain = false) private long parent; @ManyToOne (fetch = FetchType.LAZY, optional = false) @JoinColumn (name = "parentId", insertable = false, updatable = false, nullable = false, unique = false) Personal parent parentEntity; // etc ...} @Entity Class Generator {@Id @ generatedValue (strategy = GenerationType.AUTO) Private Long ID; // etc ...}

Then, removing the contents of the parent can in any way be cascade of the child without adding an additional relationship to the parent?

A solution that uses only JPA annotation will be given priority, but any help would be appreciated.

No it is not possible.

Cascades (of any kind) cross the relationships if you do not say JPA in relation to A to B. (even if it is from B to A), then it does not automatically pass it can.

On one side note: Specify only parents ID instead of parent unit is making it even more difficult, either hibernate / jpa is not the right device you are doing or hugging you It needs how it works, which means that the objects are to be specified and maintained.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -