Developer CVS has just been updated with a whole lot of new code to improve the handling of many-to-many associations. (Public CVS is about 5 hours behind normally).
If you are daring and want to simplify the management of N:M associations I would love you to try out the new version.
The changes are as follows:
1) XML Mapping of the association has changed to look something like the following:
As you can see there is now a toClassTarget. Setting this makes the association BiDirectional. Leaving it blank should keep the association uni-directional.
2) There is no need to have a separate class for the management of the association. The framework will add/delete records in the association table as required.
3) The association table should ONLY contain columns for holding the key fields of classA and classB. Anything else is ignored.
4) Testing has been done on save/retrieve only at this stage and there is a unit test in CVS that shows how it works.
Overall this approach is a lot more intuitive and should be much simpler to use.
I still need to do more work, but I'd love it if people could try it out and give me some feedback.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
Developer CVS has just been updated with a whole lot of new code to improve the handling of many-to-many associations. (Public CVS is about 5 hours behind normally).
If you are daring and want to simplify the management of N:M associations I would love you to try out the new version.
The changes are as follows:
1) XML Mapping of the association has changed to look something like the following:
<association fromClass="NunitTests.InheritedClasses.M2MA"
toClass="NunitTests.InheritedClasses.M2MB"
cardinality="ManyToMany"
fromClassTarget="M2MBCollection"
toClassTarget="M2MACollection"
retrieveAutomatic="true" saveAutomatic="true" deleteAutomatic="true">
<associationTable name="ManyToManyAB">
<fromClassKey name="GUIDValue" column="AGuidValue" />
<toClassKey name="GUIDValue" column="BGuidValue" />
</associationTable>
</association>
As you can see there is now a toClassTarget. Setting this makes the association BiDirectional. Leaving it blank should keep the association uni-directional.
2) There is no need to have a separate class for the management of the association. The framework will add/delete records in the association table as required.
3) The association table should ONLY contain columns for holding the key fields of classA and classB. Anything else is ignored.
4) Testing has been done on save/retrieve only at this stage and there is a unit test in CVS that shows how it works.
Overall this approach is a lot more intuitive and should be much simpler to use.
I still need to do more work, but I'd love it if people could try it out and give me some feedback.
- Richard.