openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Simone Gianni (JIRA)" <j...@apache.org>
Subject [jira] Commented: (OPENJPA-84) Escape sql reserved words in column names
Date Wed, 16 Sep 2009 16:41:57 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-84?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12756101#action_12756101
] 

Simone Gianni commented on OPENJPA-84:
--------------------------------------

This issue is big because it also limits portability to different databases. For example,
having an entity named "User" is not a problem in MySql or Hsql, but is an error in Derby.


While quoted names makes SQL less readable, having to name your entities depending on the
kind of database or adding table annotations for each entity just to make sure they don't
cause errors makes it far more ugly.

> Escape sql reserved words in column names
> -----------------------------------------
>
>                 Key: OPENJPA-84
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-84
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Roger Keays
>
> OpenJPA does not escape reserved words in SQL queries when they are used as column names.
To escape a reserved name you just put it in quotes:
> INSERT INTO FB_PRIVILEGES (comment, inheritable, level, role, type, username, item_uuid)
...
> on oracle, becomes 
> INSERT INTO FB_PRIVILEGES ("comment", inheritable, "level", role, "type", username, item_uuid)
...
> Looking at the code in DBDictionary, it appears that the escaping is done for table and
sequence names by appending a numeral to the name. There isn't really any good reason to do
this instead of quoting the identifier.
> table.name identifiers would have to be escaped as "table"."name" if both table and name
were reserved words.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message