Jason -- I'm able to recreate your failure when running against MySQL and a hacked up runtime. Can you try running with the following property[1] set ?
Thanks, Rick [1] <property name="openjpa.jdbc.DBDictionary" value="postgres(supportsDelimitedIdentifiers=false)"/> On Thu, Apr 26, 2012 at 10:03 AM, Jason <[email protected]> wrote: > Rick, > > If I wrap the reserved word in quotes (\"...\"), then the column is > created correctly. Here is the generated create table sql: > > CREATE TABLE xxx (guid BIGINT NOT NULL, approved BOOL, "grant" > VARCHAR(64), PRIMARY KEY (guid)); > > Yet, when I try to persist to that table, OpenJPA runs an "alter table" > command. Since the column already exists, an exception is thrown. > > org.apache.openjpa.**persistence.**PersistenceException: ERROR: column > "grant" of relation "xxx" already exists {stmnt 726853985 ALTER TABLE study > ADD "grant" VARCHAR(64)} [code=0, state=42701] > at org.apache.openjpa.jdbc.meta.**MappingTool.record(** > MappingTool.java:558) > at org.apache.openjpa.jdbc.meta.**MappingTool.record(** > MappingTool.java:456) > at org.apache.openjpa.jdbc.**kernel.JDBCBrokerFactory.** > synchronizeMappings(**JDBCBrokerFactory.java:160) > at org.apache.openjpa.jdbc.**kernel.JDBCBrokerFactory.** > synchronizeMappings(**JDBCBrokerFactory.java:164) > at org.apache.openjpa.jdbc.**kernel.JDBCBrokerFactory.**newBrokerImpl(* > *JDBCBrokerFactory.java:122) > at org.apache.openjpa.kernel.**AbstractBrokerFactory.**newBroker(** > AbstractBrokerFactory.java:**210) > at org.apache.openjpa.kernel.**DelegatingBrokerFactory.**newBroker(** > DelegatingBrokerFactory.java:**156) > > > Regards, > Jason > > > On 04/25/2012 02:28 PM, Rick Curtis wrote: > >> Hmm, that is a super old JIRA. I would expect that this should work. Your >> original post said that the exception happens when creating tables... what >> happens if you create the tables by hand and delimit this table name via >> annotations (via \"...\")? Does the manual delimiter work at runtime? >> >> Thanks, >> Rick >> >> On Wed, Apr 25, 2012 at 11:55 AM, Jason<[email protected]> wrote: >> >> Rick, >>> >>> I am using OpenJPA v2.1.1. >>> >>> I did find this open bug related to the issue:https://issues.apache.** >>> org/* <https://issues.apache.org/*> >>> *jira/browse/OPENJPA-84<https:**//issues.apache.org/jira/** >>> browse/OPENJPA-84 <https://issues.apache.org/jira/browse/OPENJPA-84>> >>> >>> >>> After reading that bug, I figured that I will have to change the name of >>> the column to not be a reserved word until this bug is implemented/fixed. >>> >>> Regards, >>> Jason >>> >>> >>> On 04/25/2012 10:01 AM, Rick Curtis wrote: >>> >>> Jason - >>>> >>>> What version of OpenJPA are you running? Can you post the full >>>> stacktrace? >>>> >>>> On Tue, Apr 24, 2012 at 11:56 AM, Jason<[email protected]> wrote: >>>> >>>> Hi all, >>>> >>>>> I am using OpenJPA with PostgreSQL. I have a table where a column has >>>>> the >>>>> name of "grant". How can I get the schema creation routine to wrap the >>>>> column name "grant" in quotes? Changing the column name is doable, but >>>>> not >>>>> preferable. >>>>> >>>>> I have tried the brain dead solution of just using: @Column(name = >>>>> "\"grant\"") >>>>> >>>>> But that results in an error...PersistenceException: column already >>>>> exists. >>>>> >>>>> Any suggestions? >>>>> >>>>> Regards, >>>>> Jason >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> > > -- *Rick Curtis*
