Case Sensitivity in JPA/EclipseLink

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Case Sensitivity in JPA/EclipseLink

William Dazey
I am having a bit of trouble deciphering the JPA spec's stance on case sensitivity, specifically with regards to database Table/Column names. I cannot find anything in the JPA specification that dictates if Table/Column names should/shouldn't default to UPPERCASE or lowercase. It appears to me that this may be provider (and more specifically database) specific. Is this a correct assumption?

The reason I ask is because I have been investigating EclipseLink's handling of DatabaseField and the case sensitivity built into that implementation (specifically equals() and hashcode()). In my investigation, I found that EclipseLink makes many assumptions about the case sensitivity of database field names. In many situations, EclipseLink basically equates the attribute value <--> database name! As a part of my fix, unfortunately, I started breaking these usecases and I am now hitting a wall because the specification is oddly silent.

For instance, assume these mappings:
public class Employee {
    @EmbeddedId EmployeeId empId;

public class EmployeeId {
    String firstName;
    String lastName;

public class Dependent {
    @Column(name="dep_name") // default column name is overridden
    String name;

        @JoinColumn(name="FK1", referencedColumnName="firstName"),
        @JoinColumn(name="FK2", referencedColumnName="lastName")
    @ManyToOne Employee emp;

public class DependentId {
    String name;
    EmployeeId empPK; // corresponds to PK type of Employee
This mapping example is taken right out of the JPA spec. The portion I am questioning is the `referencedColumnName`. Notice that in this example, the mapping uses the lowercase, attribute names. There are other examples of `referencedColumnName` in the specification that use UPPERCASE (but the specification fails to show the mappings that the UPPERCASE are referencing).

Consider in the above usecase if the `referencedColumnName`were given as UPPERCASE. Should we assume the reference ignores case and just figure it out? or should we fail with an error like:
missing FK reference column "FIRSTNAME" in table "Employee"

Should our implementation ignore case by default? There currently exists a Platforms to change that default (org.eclipse.persistence.internal.databaseaccess.DatabasePlatform.shouldIgnoreCaseOnFieldComparisons) and that default is false. I think that default may be fine, but it depends on how we want to handle when users pass in specific cased strings and how we handle them.

Will Dazey

eclipselink-dev mailing list
[hidden email]
To unsubscribe from this list, visit