Hello all,

I have been researching relationships between entity beans. Especially into
the area of applying constraints between properties on different beans.

I found the container managed relationships in the EJB2.0 spec interesting.
But I am not convinced that they will solve some important problems.


+ Lets look at this hypothetical example


-----------        Bob-Jim (1..1)                 ------------
|BobBean  |  <----------------------------------> | JimBean  |
| getJim()|        constraint:                    |  getBob()|
| +value  |          bob.value > jim.value        |  +value  |
-----------                                       ------------

There is a Bean called Bob and a bean called Jim. both have a
single property called value.

There is a bi-directional, one to one relationship between bob beans and jim
beans.


+ How can we make sure the constraint will always hold?
If the client modifies jim.value then we must validate it against bob.value,
and vise-versa.


+ How should we implement the constraint?

>From an encapsulation point of view The BobBean should not know about the
JimBean (vise versa). Therefore relationship should be modelled as a
seperate object which uses the BobBean and the JimBean.


+ How does the relationship object intercept the calls to set property
methods?

Use the Observable pattern.  If we look at the JavaBeans API(not EJB) there
is some interesting functionality defined.  A bean may add a
VetoableChangeListener. Using this change listener you can add Vetoable
change listeners to specific properties. This is exactly the behaviour we
require.

A VetoableChangeListener allows a property change event to intercepted. And
if the change causes an invalid state the change can be cancelled.


+ How can we implement this Pattern inside a Container?

Is this pattern something that we must implement from scratch? Or are there
features of the container which we can use?

Now this is the tough bit, which I am working on at the moment.

Any ideas would be appreciated

Greg.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to