This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I know that an unidirectional ManyToOne doesn’t support deletion in cascade so my solution was to put it bidirectional…of course, this bring the issue that you probably don’t need it in the other end of the relationship…but I think that I could place the getter and setter methods that hold my relation private and fetch my collection lazy…there! Problem solves!
However when I consult my boss he says that this was not a good approach to solve this problem, that my solution make the classes dirty!, that he rather to make this deletion thing with a query and then delete the other entity (the entity who should have the OneToMany side).
So my question is: is this true? My solution isn’t a good approach???
I believe the your boss is correct, but before two things:
1- A relationship OneToMany is the same thing that ManyToOne.
2- A relationship is bidirectional or not if you put in the code the correct method to return anohter bean and the <crm-field> in the descriptor,
in the relationship role in the descriptor you should write the source and destiny beans,
What is my opinion ? put <cascade-delete /> in the bean with multiplicity One
Joined: Sep 21, 2009
That's what I think too: I mean, I could fix the problem with multiplicity OneToMany, but...they said to me that this approach make my class dirty because every time that I have to bring the entity that holds the OneToMany relationship then it will load the entire collection, but I think that if I put fetch = fecth.LAZY I won't need to worry about that collection….
Joined: Feb 24, 2009
I have a doubt.
What was the first problem ?
because you have spoken about multiplicity, cascade delete, relationships.
Joined: Sep 21, 2009
The problem is about if it is a good approach to put a class with a OneToMany relationship, even if it doesn't need to know about the collection that it holds in order to let the container handle everything with cascade...