Bug 1003468 - HHH-8464 Using JPA2 specific quoting character (double quote) for JoinColumn results in DuplicateMappingException.
HHH-8464 Using JPA2 specific quoting character (double quote) for JoinColumn ...
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ER4
: EAP 6.2.0
Assigned To: Brett Meyer
Zbyněk Roubalík
Russell Dickenson
Depends On:
Blocks: 1010467
  Show dependency treegraph
Reported: 2013-09-02 02:49 EDT by dstephan
Modified: 2015-09-01 00:00 EDT (History)
6 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Using a JPA2-specific quoting character (`"`) for a JoinColumn would result in a `DuplicateMappingException`. This issue was caused by the quoting character not being normalized internally. This issue has been fixed in this release so that using `"` for a JoinColumn is now normalized properly, and will no longer result a `DuplicateMappingException`.
Story Points: ---
Clone Of:
Last Closed: 2013-12-15 11:14:23 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description dstephan 2013-09-02 02:49:09 EDT
A JoinColumn like the following:

@JoinColumn(name="\"NAME#\"", insertable=false, updatable=false)
private OutTx transaction;

will result in:

org.hibernate.DuplicateMappingException: Table [XYZ contains phyical column name `NAME#` represented by different logical column names: `NAME#`, "NAME#"

It seems like these lines in EJB3JoinColumn.addColumnBinding() won't replace the mapping with backticks:

if ( StringHelper.isQuoted( getLogicalColumnName() ) || StringHelper.isQuoted( getLogicalColumnName() ) )
{ logicalColumnName = StringHelper.quote( logicalColumnName ); }
Comment 1 dstephan 2013-09-02 02:51:06 EDT
Hibernate Jira : https://hibernate.atlassian.net/browse/HHH-8464
Comment 2 Brett Meyer 2013-09-03 12:49:11 EDT
As described on HHH-8464:

Dave, the mapping looks off (I think).  In the test case, OutboundDistributorEligibility has the following:

    @Column(name = "\"WETRN#\"", precision = 9, scale = 0)
    private BigInteger transactionNumber;


    @JoinColumn(name="\"WETRN#\"", insertable=false, updatable=false)
    private OutboundNewDistributorTransaction transaction;

That would try to create 2 physical columns with the "WETRN#" name.  It looks to me like they're trying to define a derived primary key from the many-to-one OutboundNewDistributorTransaction foreign key (ie, the OutboundDistributorEligibility PK is the same as its FK referring to to OutboundNewDistributorTransaction).  Instead, try this:

Completely remove OutboundDistributorEligibility#transactionNumber.  Add @Id to OutboundDistributorEligibility#transaction.  OutboundDistributorEligibility.OutboundDistributorEligibilityPK will also need updated to refer to "transaction" instead of "transactionNumber".

Please give that a shot first.  I'll leave this open for now.
Comment 3 Brett Meyer 2013-09-05 14:30:57 EDT
Dave, regardless of the mapping, there was a legitimate issue.  Corrected upstream in HHH-8464.  Do they need a one-off, or is this purely the permanent fix?  If one-off, create an additional BZ?
Comment 4 Brett Meyer 2013-09-18 10:05:56 EDT
Assuming this is the permanent fix (EAP 6.3.0).  Dave, open a one-off if needed.
Comment 5 Brett Meyer 2013-09-19 22:28:56 EDT
Dave stated a one-off wasn't needed -- easy workarounds are acceptable.
Comment 8 Brett Meyer 2013-09-25 11:54:33 EDT
Actually, this will go into EAP 6.2.0 ER4's upgrade to Hibernate ORM 4.2.6.Final in 1010467.
Comment 12 Martin Simka 2013-11-20 04:17:41 EST
verified on EAP 6.2.0.CR2

Note You need to log in before you can comment on or make changes to this bug.