2013/7/29 Christopher Deckers <[email protected]> > Hi electrotype, > > > Chrriis, if I understand well, you would use entities like : >> ------------ >> >> public class Person { >> long id; >> String name; >> String someOtherSimpleProperty; >> } >> >> public class Address { >> long id; >> String streetName; >> String someOtherSimpleProperty; >> } >> > > If an address is bound to a person and retrieved passing Person objects, > then we could have the Person as a field of Address. A leaf can know its > parents if it is always retrieved through the parent. > This means that: > > >> public class PersonAddress { >> Person person; >> Address address; >> } >> > > ... may not be useful. >
Every time I have tried to tackle these topics with jOOQ or before jOOQ, I ran into the limitations imposed by the object-relational impedance mismatch. While M:N relations are somewhat feasible through helper classes as above, or though sophisticated collections such as provided by Eclipse's EMF, there is simply no sensible way to express a M:N:O relation in Java, not to speak of an M:N:O:P relation. While such relations are not easy to model with SQL tables either, they are very easy to model with SQL views (i.e. with JOINs). Once you have such a complex table source, you just add predicates on 3 out of 4 relations (e.g. M, O, P) and you get something like a sophisticated view on N. The OR impedance mismatch already displays how M:N can create a mess, which is why I'm not trying to solve any of these problems in jOOQ. You know your SQL / Java domain models better than jOOQ, and you can always inject RecordMappers and since jOOQ 3.1 even a central RecordMapperProvider: http://www.jooq.org/doc/3.1/manual/sql-execution/fetching/pojos-with-recordmapper-provider In a way, jOOQ forces you to cleanly separate your relational model (possibly driving a better relational design) from your OO model (possibly driving a better OO design) at the cost of having to map things yourself again. I'm gathering a lot of information to unleash a series of blog posts around these topics, i.e. how these mappers (ORMs and LINQesque query-it-all APIs) will always create an impedance mismatch. -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
