Hi,
thanks for the quick and in-depth answer!
On 02.10.2009, at 12:34, Niclas Hedhman wrote:
1. Correct, Qi4j will not know (and we have not found any reason for
it to know it either) any 'directional' information in associations.
If you can give us some usecases when this information is needed,
perhaps we can evaluate its relevance.
2. In general, try to avoid bi-directional associations. It simplifies
a lot. For instance, in your model you put in a association to
"company" for a Person (which should be Employee), but perhaps the
Person works for multiple Companies at the same time.
3. Qi4j has the notion of Aggregated, so if for instance the
'association owner' is deleted, then the associated entities are also
deleted. Aggregated is built-in with that semantics, but we expect
more semantics to follow in later versions, possibly supporting
"Aggregate Roots" and "Aggregate Locks & Isolation".
Good to know, thanks!
If we elaborate on your example a little bit. Employees are really its
own Entity (actually, I would try to make it a Value composite
instead), since there will be additional properties associated with
the employment and not the Person. And assuming Company is a
shareholding company, we will have Shareholding as another Entity, and
those shares can be held by either Company or Person, a.k.a
LegalEntity...
Person extends LegalEntity;
Employee {
Association<Company> company();
Association<Person> person();
Property<Date> startedDate();
}
Shareholding {
Association<LegalEntity> owner();
Property<Long> shares();
}
Company extends LegalEntity {
@Aggregated
ManyAssociation<Employee> employees();
@Aggregated
ManyAssociation<Shareholding> owners();
}
If the Company is deleted (can not actually happen in the real world)
the shareholdings and employees will be deleted with it, but the
associations in Employee and Shareholding are not propagated to its
associations.
Makes sense?
Yes, it does. However, the model was just a simplified example of
things I have come across in the past and I cannot say that I would
not expect this to happen again. On the other hand I have to let your
line of thinking sink in a bit more to see if those were generally
cases of a not-so-good domain model.
Anyway, I know now what Qi4j's "limitations" are in that respect and
how to get around them and that's great.
Thanks again,
Cheers,
Robert
Cheers
--
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev