openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Dick <michael.d.d...@gmail.com>
Subject Re: Using reserved keywords for Entity names
Date Thu, 25 Jun 2009 17:53:02 GMT
I suspect that will resolve the problem - provided the name isn't another
reserved word.

It seems a little odd that we 'fix' reserved words for column names
automagically but don't do the same for table names. I can't think of a
reason why this would be desirable offhand so I'd vote for opening a JIRA
(subtask of the one that fixed the problem for column names) to consistently
adjust, or not adjust, for reserved words..

Just my $0.02
-mike

On Thu, Jun 25, 2009 at 11:48 AM, Albert Lee <allee8285@gmail.com> wrote:

> Have you try to override the table name using @Entity @Table(name="xxx")
>
> Albert Lee.
>
> On Thu, Jun 25, 2009 at 11:18 AM, Rick Curtis <curtisr7@gmail.com> wrote:
>
> >
> > I ran into a problem(I think) when doing some testing on Derby where I
> have
> > an Entity named User and I'm having OpenJPA build my DB tables. Since
> > 'User'
> > is a reserved word on Derby, the SQL that OpenJPA generates to create my
> > User table blows up[1].
> >
> > Each DBDictionary has a set of 'reserved words' but that list of words
> > isn't
> > used for table names, they are only used for column names. If a column
> name
> > matches a reserved word, we append a 0 to the name or something like
> that.
> > I'm wondering if we should do something similar with the table names?.
> >
> > I'm going to try to find some time soon here to look at the spec to see
> if
> > this issue is discussed. Any thoughts or comments?
> >
> > -Rick
> >
> > [1]
> > 6484  embeddables  TRACE  [main] openjpa.jdbc.SQL - <t 24634836, conn
> > 9566840> executing stmnt 24008846 CREATE TABLE User (id INTEGER NOT NULL,
> > USER0 VARCHAR(255), user_name VARCHAR(255), city VARCHAR(255), state
> > VARCHAR(255), street VARCHAR(255), zip INTEGER, COORDINATES_ID INTEGER,
> > number VARCHAR(255), type VARCHAR(255), PRIMARY KEY (id))
> > 6484  embeddables  TRACE  [main] openjpa.jdbc.SQL - <t 24634836, conn
> > 9566840> [0 ms] spent
> > Exception in thread "main" <openjpa-0.0.0-rnull nonfatal general error>
> > org.apache.openjpa.persistence.PersistenceException: Syntax error:
> > Encountered "User" at line 1, column 14. {stmnt 24008846 CREATE TABLE
> User
> > (id INTEGER NOT NULL, USER0 VARCHAR(255), user_name VARCHAR(255), city
> > VARCHAR(255), state VARCHAR(255), street VARCHAR(255), zip INTEGER,
> > COORDINATES_ID INTEGER, number VARCHAR(255), type VARCHAR(255), PRIMARY
> KEY
> > (id))} [code=30000, state=42X01]
> >        at
> > org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:553)
> >        at
> > org.apache.openjpa.jdbc.meta.MappingTool.record(MappingTool.java:453)
> >        at
> > ....JDBCBrokerFactory.synchronizeMappings(JDBCBrokerFactory.java:159)
> > ...
> > --
> > View this message in context:
> >
> http://n2.nabble.com/Using-reserved-keywords-for-Entity-names-tp3156045p3156045.html
> > Sent from the OpenJPA Developers mailing list archive at Nabble.com.
> >
> >
>
>
> --
> Albert Lee.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message