Handle bidirectional associations.
----------------------------------
Key: HIB-219
URL: http://jira.andromda.org/browse/HIB-219
Project: Hibernate Cartridge
Type: New Feature
Versions: 3.0M3, 3.0RC1, 3.0 RC2, 3.0 Final, 3.0.1, 3.1M1, 3.1-RC1, 3.1,
3.2-RC1
Reporter: Benjamin Lerman
Assigned to: Carlos Cuenca
Attachments: hibernate-patch
The hibernate cartridge do not take into account if an association is
bidirectional when it does generate the getter setter for the association.
That means it is of the responsibility of the user to synchronize the two end
of the associations.
I join a patch that add a "handleBidirectionalAssociations" option to the
hibernate namespace. When this option is enable, the getter and setter of the
bidirectional associations are modified so that synchronization of bother ends
is automatically handled.
For this, I do the following:
The property is renamed with a Internal suffix. There is a usual getter/setter
for this internal attribute, but with a package protected visibility.
The hibernate mapping file are modified to point to this internal attribute.
An Accessor class is created on the same package as the entity class that has
public static method that allows direct access to the internal property.
For a *-to-One relation, usual getter, setter are generated, that
automatically handle other end of the association, using the Accessor if needed.
For a *-to-Many relation, 4 methods are created: getter, setter, adder and
remover. All handle bidirectionality. The getter should return an unmodificable
collection but this is still to do because finding the correct
Collections.unmodifiableXXX to use does not seem that easy.
I join the patch as well as the meta-facade model
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.andromda.org/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com