Hello all, Happily using jOOQ for a while now, I'm starting to use it for a little more than just SQL generation and I'm struggling a little when working with keys (primary, unique, foreign).
First, the Key interface doesn't have any generic information about the key type: the only generic parameter represents the type of the owner table. So for example, although both ends of a foreign key should have the same type, there is no type-safety to guarantee that. And more generally, it's problematic to write methods expecting a key with a certain type. I tried other types to add genericity to my keys, like Row and its numbered friends, or jOOL tuples, but in the end it seems RecordType is more appropriate. Its parameter being a single Record type rather than several data types, it's easier to work with. For example when extracting values of a key implementing RecordType<K>, I return a record of type K ; this can't be done with a Row, short of writing all 22 overloads. But then sometimes I need to work with key values only, rather than key fields or a key record (for example when comparing values from both ends of a foreign key, I cannot compare full records since key columns may not have the same name). Technically I could use RecordType again (since anyway all field containers are implemented on top of a Fields object), but judging from the name of the interface, its documentation, and the fact that DSL.recordType only take Field arguments, it doesn't feel like this type is meant to contain values. So, to hold key fields: - Use Key, adding a type parameter? - Use RecordType? (but RecordType only contains Fields and not TableFields as do Key) - Make Key extend RecordType ? To hold key values: - Create some new "RecordValue<R>" type, symmetrical to RecordType<R> ? Or, giving up the difference between key fields and key values, use a single "RecordTuple<R>" type to hold anything? Row could even extend this type (with each RowX<...> extending RecordTuple<RecordX<...>>). -- After writing this long and mostly vague post, I realize I don't really know where I'm going with all that. Hoping someone may see things a little more clearly... Please share! -- 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/d/optout.
