Should I use composite primary keys in Grails? -
the grails docs discourage use of composite primary keys, in this video (26:00 - 29:00) @burtbeckwith uses composite primary keys speaks performance benefits of mapping of join tables domain classes opposed using collections. raises several questions:
- why grails docs discourage use of composite primary keys?
- why burt using composite key? tried without 1 , seems work fine. didn't override
hashcode
orequals
. - burt using grails 1.3 when video made, performance concerns regarding collections still valid? can test myself turning on sql logging, haven't done yet.
hibernate prefers simple primary key, if there's natural unique key (e.g. username in user table) since auto-incrementing long values simpler use foreign keys. supports other approaches of course, , gorm.
the reason use composite pk in userrole table keep same implicitly created join table when use many-to-many in gorm. approach proposed intended same far database concerned, more performant, , have more control on customizing join table. feel free change composite pk 2 foreign keys (ideally unique index) , add regular single-column primary key. fine long don't plan on using gorm many-to-many join table.
Comments
Post a Comment