Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: re[eclipselink-users] served keywords

I guess the solution I have come up with works the best... I assume i'm not using JPA 2.0 because all my attempts have failed at trying to get the delimited-identifiers working..

and adding the double quotes to the column works fine if there are no joins in the query.. but when there are joins that also fails..

so what I have done is added a query hint to all the queries that use this table to make it join it to another table, so that the query comes out looking like

select ... t0.from, t0.to, t1.???, t1.??? ... from ... join ...


Derek Knapp

Tom Ware wrote:
I'm afraid there is some confusion about how this all works.

At the moment, the universal setting is available only as part of JPA 2.0. The configuration is part of persistence-unit-defaults in orm.xml.

    <persistence-unit-metadata>
        <persistence-unit-defaults>
            <delimited-identifiers/>
        </persistence-unit-defaults>
    </persistence-unit-metadata>

That setting will caused all identifiers to be delimited automatically by EclipseLink. Note: There is no persistence-unit property for this since it is a first-class part or JPA 2.0 orm.xml.

If you want to be selective about what fields are delimited, simply delimit them in our annotations or your orm.xml with the double quote and the delimiter will be used.

    @Column(name="\"F_NAME\"")
    private String firstName;

Sorry for the confusion,
-Tom

Michael O'Brien wrote:
Mike,
Correct, this property has been added by Tom to PersistenceUnitProperties.java - therefore it can be defined in xml below or passed dynamically in a Map to PersistenceProvider.createEntityManagerFactory() (for SE clients) like other properties..

    thank you
    /michael

Mike Kienenberger wrote:
This is a guess, but it's a pretty reasonable guess based on other
eclipselink.x parameters.

Put it in META-INF/persistence.xml:

<persistence...>

    <persistence-unit ...>
        <properties>
<property name="eclipselink.database.delimiters" value="true"/>
        </properties>
    </persistence-unit>

</persistence>


On Fri, Sep 11, 2009 at 6:15 PM, Derek Knapp <derek@xxxxxxxxxxxxxx> wrote:
anyone know where to put

"eclipselink.database.delimiters"="true"


Derek


Derek Knapp wrote:

I'm using mysql, this is the complete query that is generated

SELECT t1."to", t1.cc, t1.bcc, t1.reportid, t1.userid, t0.userid,
t0.firstname, t0.lastname, t0.phoneno, t0.cellno, t0.email, t0.password, t0.managerid, t0.title, t0.disclaimer, t0.signaturestatus, t0.signatureline,
t0.country, t0.region, t0.regionid, t0.city, t0.cityid, t0.office,
t0.officeid, t0.team, t0.teamid, t0.adminlevel, t0.companyid FROM users t0, reportdistribution t1 WHERE (((t1.reportid = ?) AND (t1.userid = ?)) AND
(t0.userid = t1.userid))

I have tried manually running it in mysql, and i get the same error

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"to", t1.cc, t1.bcc, t1.reportid, t1.userid, t0.userid, t0.firstname,
t0.lastnam' at line 1


Tom Ware wrote:

Hi Derek,

  What does the full SQL string you are getting look like?

  What database are you on?

-Tom

Derek Knapp wrote:

using the "\"to\"" worked well, and I was very happy, until i tried joining
this to another table

which would cause it to generate sql similar to select table."to" from
....

which is also invalid... so I'm trying to find more information on the

"eclipselink.database.delimiters"="true"

property, but google isn't doing me any good.. only thing I find is my
question



Derek


To handle reserved words you need to quote them. You can do this when you define your mappings, just give the column name as "\"TO\"" instead of "to".

EclipseLink 2.0 (1.2 as well) (JPA 2.0) support automatically quoting
columns as well.

I think the property is,
"eclipselink.database.delimiters"="true"


Derek Knapp-3 wrote:
I'm switching to exlipselink from toplink for some of the new features (mainly the batch and fetch query hints) however, I'm encountering one problem.. I have some entities with columns that have reserved names..
for example, "to" and "from" (it is a table to store an email). The
problem is with the following query.

"select e from Email e where e.id = :id"

in toplink, this wasn't a problem.. the query it would generate is

"SELECT t0.id, t0.subject, t0.to, t0.from FROM email t0 where t0.id = 1"

but in eclipselink, its not adding the t0. to the list of columns... > aka
its generating the following sql

"SELECT id, subject, to, from FROM email t0 where t0.id = 1"

which is clearly invalid....


is there any way in eclipselink to make it add the t0. ? or is the only solution to rename the columns in the database (which would be a large
amount of work :( )


-----
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland
http://www.eclipse.org/eclipselink/
EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink ,
http://wiki.oracle.com/page/TopLink TopLink
Forums: http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink ,
http://www.nabble.com/EclipseLink-f26430.html EclipseLink
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users

________________________________
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


------------------------------------------------------------------------

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top