> "Thinking about this" is already on the roadmap > :-)https://sourceforge.net/apps/trac/jooq/ticket/644
great!:) > From what I understand, Postgres just "hides" a foreign > key relationship between cities and capitals behind the notion of one > table inheriting from another? I'm not completely sure, but given the fact that inherited tables in the current implementation do not inherit indexes (see 'Caveats' in the PostgreSQL page), i guess capitals is implemented as a separate table with the same fields as cities + a state. > > To do anything useful with this in jOOQ, the inheritance hierarchy > > would need to be reflected in the generated Table and Record classes > > though, and some tricks would probably be required to allow casting > > between super and sub types. > > Another thought is to simply let generated tables/table records extend > each other. Yes, a matching hierarchy on the java and database side is probably the most natural way to deal with this. ... I'm not sure about the exact implementation details though :) I think there are some difficulties too when it comes to type casting. A "selectFrom(Cities.CITIES)" will return some CitiesRecords that are in fact CapitalsRecords. There needs to be some way to cast them to CapitalsRecord. You could probably add the pg_class.relname column (see PostgreSQL page) to every selectFrom-generated SQL to find out what the actual subtype of returned 'cities' records is and add a CapitalsRecord to the Result set instead of a CitiesRecord when appropriate, but then you're still missing the CapitalsRecord's 'state' value.
