quoted identifiers [message #646766] |
Thu, 30 December 2010 20:26 |
Martin Geisse Messages: 24 Registered: July 2009 |
Junior Member |
|
|
Since I just got very useful help, I'll post my next problem
I am using PostgreSQL, so I have to double-quote all identifiers or they'll be implicitly lower-cased. I'd prefer to preserve case since "lastLoginAttemptIpAddress" is so much more readable than "lastloginattemptipaddress".
I have created an orm.xml file with <delimited-identifiers /> (full contents below). That caused EclipseLink to quote most of the identifiers, but it specifically did not quote the column name when defining a foreign key constraint. How can I tell EL to quote *all* identifiers?
I have also read about using quotes in the explicitly specified table / column names to cause EL to quote identifiers. However, (1) that forces me to specify names twice (I already did so in the property accessor names) and in a manner that is invisible to refactoring tools, (2) it is wrong -- the quotes aren't part of the name, (3) it forces me to fix quoting at POJO level when it is actually a specific trait of the database system I am using, (4) it is unclear to me how this could fix the problem when <delimited-identifiers /> doesn't.
orm.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<entity-mappings version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd">
<description>description here</description>
<persistence-unit-metadata>
<persistence-unit-defaults>
<delimited-identifiers />
</persistence-unit-defaults>
</persistence-unit-metadata>
</entity-mappings>
entity class:
@Entity
public class UserX {
...
@Id
@GeneratedValue(generator = "UserX_id_seq")
@SequenceGenerator(name = "UserX_id_seq", allocationSize = 1)
public int getId() { ... }
...
@ManyToOne(fetch = FetchType.LAZY, optional = false)
public UserX getModificationUser() { ... }
the generated query (note the missing quotes around the column name):
ALTER TABLE "UserX" ADD CONSTRAINT "FK_UserX_modificationUser_id" FOREIGN KEY (modificationUser_id) REFERENCES "UserX" (id)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02391 seconds