Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] NamedQuery generating bad sql for quoted column

Sorry, I hit send to quickly. Its actually a double quote, so your fields would need to be defined as:
@Column(name="\"Key\"")

Best Regards,
Chris

On 13/08/2010 12:13 PM, Christopher Delahunt wrote:
The character you are using as a delimiter is wrong, it should be the single quote "'".
Best Regards,
Chris

On 13/08/2010 12:05 PM, themitchy wrote:
Ok, so I have the following NamedQuery:

@NamedQuery(name = "findComp", query="SELECT c FROM Component c")

And column in an entity:

    @Column(name="`Key`")
    private String key;

I get a SQL error for the generated SQL:

... `Key` AS `Key`22 ...

Which is obviously bad SQL but without the quoted field name the SQL is
equally wrong:

... Key AS Key22 ...


I don't have the option of renaming the columns. I'm prototyping something to prove how great JPA/EclipseLink is so we can start using it in our team. Obviously I'll get laughed at if there's just no way to handle reserved
words like this :-)

I'm using EclipseLink 2.0




Back to the top