This content has been marked as final.
Show 2 replies
-
1. Re: Best approach to manage bidirectional relations
gaborj Apr 15, 2010 6:14 PM (in response to rvazquez)- One point is to separate the model from business logic, so that you can refactor your tables and model beans with minimal impact on BL.
- The other way e.g. you do not define Foreign Keys in DB and/or dependencies in your entities then they are loosely coupled but actually your model dependencies are coded in your BL tier, and your table dependencies are hidden in the Model tier which is not safe in most cases.
To clear up things: in current implementation both of these (and much more) are possible, user is never forced to go with 1.
In your example use case this is some kind of validation. In most cases validation is in close relation to the Model field values and the implementation can be easily covered by Hibernate Validator. There are exceptional cases when validation is more complex and rather part of BL, I experience such almost in each project, then I usually follow the old proven Transfer Object/Value Object pattern, but I think this is the exception here. So, I would follow 1.
-
2. Re: Best approach to manage bidirectional relations
rvazquez Apr 16, 2010 3:29 PM (in response to rvazquez)Gabor,
Thank you very much for your reply.