| Summary: | DB column names in lowercase are capitalized in referencedColumnName attribute | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | welljim |
| Component: | Eclipselink | Assignee: | Nobody - feel free to take it <nobody> |
| Status: | REOPENED --- | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | tom.ware |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Mac OS X - Carbon (unsup.) | ||
| Whiteboard: | |||
Use delimiters either by delimiting the individual columns in your annotations.
e.g. @JoinColumn(name = "\"viewId\"", referencedColumnName = "\"id\"")
Or by setting it to the default in your orm xml
i.e.
<persistence-unit-metadata>
<persistence-unit-defaults>
<delimited-identifiers/>
</persistence-unit-defaults>
</persistence-unit-metadata>
I tried delimiting the column names as suggested, the workaround produces the following results: - Dali plugin (i.e., Eclipse Editor) no longer underlines the column names as incorrect (please note that this is also the case without the delimiters) - However, the exact same errors that I described originally are still produced at runtime, despite the use of the delimiters. In other words, enclosing mixed lowercase/uppercase column names inside escaped double quotes (\") cannot be used as a workaround, delimiting such column names does not seem to have any effect. Perhaps for new projects the cost of changing all column names in a DB can be manageable (although I suspect many would criticize an ORM provider for imposing such restrictions). But for existing systems such a change on the DB level may be prohibitive. I'm reopening the issue for your consideration, at the moment the only workaround seems to be the use of capitalized names in Eclipse, though that is making development really difficult (i.e., we have about 50 entities in the package explorer that are marked with the red "x" (i.e., to imply that they contain errors). We are no longer able to distinguish which classes do have real errors without inspecting them one by one, at every change we make in the code. This is a ton of work.. My quick run our our delimited model shows me case being maintained property with delimited identifiers used. Is it possible to post a recreation of the issue? What DB are you using? The DB is MySQL (5.1.41, community ver) The problem appears only when entity keys are composite, where referencedColumnName needs to be explicitly defined in relationships. I'll try to simulate it outside our installation and post an example. The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink |
Build Identifier: 20100218-1602 If a column name in the DB contains lowercase characters, then it is not possible to correctly use that column in the referencedColumnName attribute. For instance, consider the following example: @ManyToOne @JoinColumns({ @JoinColumn(name = "viewId", referencedColumnName = "id"), @JoinColumn(name = "customerId", referencedColumnName = "customerId") }) private MyEntity myEntity; Although the DB columns and corresponding entity fields are called "id" & "customerId", using those names in "referencedColumnName" results in errors during runtime: org.eclipse.persistence.exceptions.QueryException Exception Description: The parameter name [id] in the query's selection criteria does not match any parameter name defined in the query. Changing the referenced column names to a capitalized equivalent as shown below, resolves the problem and the application runs as expected. However, now the Eclipse editor does not recognize the capitalized names and it underlines them in red with the following error: Referenced column "ID" in join column "viewId" cannot be resolved. & Referenced column "CUSTOMERID" in join column "customerId" cannot be resolved. The errors appear in the Eclipse editor after establishing a DB connection in the JPA plugin (Database Connections) @ManyToOne @JoinColumns({ @JoinColumn(name = "viewId", referencedColumnName = "ID"), @JoinColumn(name = "customerId", referencedColumnName = "CUSTOMERID") }) private MyEntity myEntity; Reproducible: Always