Last updated by vguhesan 6 months ago
These are lists of reserved keywords for various databases that are commonly used as table or column names. When naming a domain class or a property, make sure that your target platforms do not reserve that name.A useful web site allows to check for different databases:http://www.petefreitag.com/tools/sql_reserved_words_checkerBut you should double check with the documentation of the database you use or plan to use in the future.
MySQL
- order
- transaction
PostgreSQL
- cast
- constraint
- user
Grails-specific reserved words
- application - clashes with the application variable
Hibernate reserved words
See the list of keywords for HQL http://www.hibernate.org/hib_docs/reference/en/html/queryhql-expressions.html.- Member - used as a Grails domain class in the default package generates an Hibernate exception when used in HQL "find" or "findAll":
If you have a domain class without package named like any class from packagejava.lang.*(e.g.System) Hibernate will try binding it to the default import and not to your domain class. Use packages!
Using reserved keywords as column names
If you have a domain field or column called "member", then the way you can construct the HQL that solves this issue is by using a "table-name as XYZ".BEFOREdef groupMemberList = GroupMember.findAll("from GroupMember where group= ? and member = ?", ...)AFTERdef groupMemberList = GroupMember.findAll("from GroupMember as gm where gm.group= ? and gm.member = ?", ...)Notice how in the above example, we used the "gm" as a way to avoid the issue.



