Problem using SQL keywords as field names in entities

If you’re using an JPA implementation in your application like hibernate you might try to name a field of an entity just as SQL keywords (e.g. ‘order’ or ‘key’). But beware of the nasty persistence provider.

You might think: “Hey it’s an persistence provider. It will be as intelligent to name the table column something like ‘xorder’ so that no syntax exceptions in the generated SQL queries arise.” No, it isn’t. In order to prevent nasty syntax exceptions keep from using those keywords.

Leave a Reply

Your email address will not be published. Required fields are marked *