Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-RC1
-
Fix Version/s: 1.1-RC1
-
Component/s: Persistence
-
Labels:None
-
Environment:any
Description
Hibernate recommends identification of natural-ids (things that would be primary keys if we were not using auto-ids). From the Hibernate docs:
"even though we recommend the use of surrogate keys as primary keys, you should still try to identify natural keys for all entities. A natural key is a property or combination of properties that is unique and non-null. If it is also immutable, even better. Map the properties of the natural key inside the <natural-id> element. Hibernate will generate the necessary unique key and nullability constraints, and your mapping will be more self-documenting."
And it also says that natural ids will work with query caching (chaper 15).
So we should be able to specify them in GORM for a performance benefit both at the database level (ok, we can specify the indices in GORM) and in the query caching (I've no idea what that entails)
GORMS nice online docs say: "With GORM's DSL you can specify which columns need to live in which indexes:"
But the GORM docs do not show a way to specify that the index should be unique. At least on MySQL, the multicolumn index created when using the index: keyword is set to NON-UNIQUE=true. But I want a unique index.
I think the GORM DSL would benefit from adding a new keyword "uniqueIndex:" for this situation.
Also, where is the reference list of all GORM DSL keywords (or whatever they're called in a DSL)?
Thanks,
Dev