Grails Domain Class without ID field or with partially NULL composite field

随声附和 提交于 2019-12-04 09:56:11

We had that problem before.

In my experience, Composite IDs are just not well supported in Grails or maybe in Hibernate.

We always find a way to have unique ID for all our domain classes.

For real tables, we just add an auto-increment field, even though if we weren't using grails we would have used a Composite key.

For database views, we usually have an ID already in one of the joined tables that ends up being unique in that context, but if we don't, there are ways to hack/simulate this. For example, in SQL, just concatenate the keys you would use in your composite key as a single field and use this as the key.

Have you tried what the Composite Ids section mentions on this reference page? I have not tried using it myself and I am not sure if this has changed in the latest version.

Also, if you look at Table B, the only values for A.id are 2 and 3 so don't you think when A.id is 1 the result would be null for B.id, C.id and varY? or was that only meant as an example?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!