Hello Andreas, To complement with what I have already said, you might want to consider this presentation here. It has some nice examples of how to model and how not to model inheritance in relational data:
http://www.slideshare.net/billkarwin/sql-antipatterns-strike-back Cheers Lukas 2012/3/2 Lukas Eder <[email protected]>: > Hi Andreas, > >> I've tried googling but beside a thread about JOOQ and Postrgres >> (http://groups.google.com/group/jooq-user/browse_thread/thread/62e4e9f7ee4af5fb/9b5f90fc63e0e1a8) >> I didn't find a hint how someone would implement simple inheritance with >> JOOQ. > > Yes, that thread was the only time that the "inheritance" subject came > up on this user group > >> What I want to do is have a java class "Contact" which is the base class of >> "User". I know that there are at least 3 different ways to design your >> database for this kind of inheritance and I'm fine with any of them. >> Is there a "JOOQ Way" to do this? Can I tell JOOQ somehow that the >> UsersRecord is actually extending the ContactsRecord? > > Inheritance has not been considered a true relational concept by most > databases (Postgres and to some extent Oracle being the only > exceptions I'm aware of). With Hibernate/JPA, there have been some > attempts of mapping Java's notion of inheritance to SQL's LEFT OUTER > JOIN clauses (i.e. if a Java User *IS* a Contact, then a SQL User can > be left outer joined to a SQL Contact). > > The "jOOQ way" to do this would thus correspond to the "SQL way" to do > it. If you want to use object-oriented inheritance in client code, you > can still create a domain model that is independent of jOOQ, and use > the various ResultQuery.fetchInto(), Result.into(), Record.into() > methods to map jOOQ records to your custom POJOs: > http://www.jooq.org/javadoc/latest/org/jooq/Record.html#into%28java.lang.Class%29 > > Of course, I'm always open to suggestions... > >> Ps.: Whats the best way to submit a bug? > > You can either send a mail to the user group, or directly create a > ticket on Trac, if you have a sourceforge account: > https://sourceforge.net/apps/trac/jooq/newticket
