I'm working on a Java/JooQ app and having a lot of cases where I am passing strings (e.g. '32f93ed0-28cb-4aa4-8ec3-7956d68c768f') around that are the primary keys of tables.
It would be nice to get some more help from the type system such as subtyping a string. You can't do that in Java but I guess you could build an ORM system that distinguishes between the key to a record and the rest of the record and that would jive well with multipart keys.
I realize you probably can't switch languages, but in a past Kotlin project I was able to get jOOQ working nicely with Kotlin's inline classes [0] as the primary keys. I can't remember exactly how I did it and don't have access to the code any more (I might have used extension functions somehow?), but it was exactly as nice as you'd expect—no risk of mixing up keys between different tables.
On further investigation, jOOQ actually has a feature which automatically generates PK classes, but it's not in the open source edition. It should, however, be possible to write your own extension that does something similar: https://www.jooq.org/doc/latest/manual/code-generation/codeg...
It would be nice to get some more help from the type system such as subtyping a string. You can't do that in Java but I guess you could build an ORM system that distinguishes between the key to a record and the rest of the record and that would jive well with multipart keys.