Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EclipseLink & Cell Names with White Space
EclipseLink & Cell Names with White Space [message #654471] Tue, 15 February 2011 22:38 Go to next message
Betsuni is currently offline BetsuniFriend
Messages: 3
Registered: February 2011
Junior Member
Performing a normal query like
List<Contact> list = em.createNamedQuery("Contact.findAll").getResultList();
gets translated into
SELECT No_, Mitgl_ in Firmenmitgliedschaft, Telex Answer Back, Profession, [...]
which results in an java.sql.SQLException because of wrong syntax. Is there any way to deal with columns containing white spaces?

I got to use MS SQL here, so the normal way of doing such a query would be
SELECT No_, [Mitgl_ in Firmenmitgliedschaft], [Telex Answer Back], Profession, [...]
I set NATIVE_SQL and SQL Server in the persistence.xml, but it did not help for this issue...
Re: EclipseLink & Cell Names with White Space [message #654477 is a reply to message #654471] Tue, 15 February 2011 22:57 Go to previous messageGo to next message
Betsuni is currently offline BetsuniFriend
Messages: 3
Registered: February 2011
Junior Member
Already found a solution/workaround:

If all the problematic column names get wrapped in the entity class, the problem disappears, for instance:
@Column(name = "[Mitgl_ in Firmenmitgliedschaft]")
Re: EclipseLink & Cell Names with White Space [message #654910 is a reply to message #654471] Thu, 17 February 2011 15:16 Go to previous message
James Sutherland is currently offline James SutherlandFriend
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

In JPA2 there is an element in the orm.xml persistence meta-data,

<delimited-identifiers>

that will have all columns delimited to allow spaces/special chars/case.

I think using,

@Column(name = "\"Mitgl_ in Firmenmitgliedschaft\"")

will also work.


James : Wiki : Book : Blog : Twitter
Previous Topic:Left Outer Join With Curly Brackets
Next Topic:JPA 1.2 Overhead
Goto Forum:
  


Current Time: Sat Nov 29 00:28:26 GMT 2014

Powered by FUDForum. Page generated in 0.04059 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software