Bug 1157597

Summary: (6.3.z) HHH-9390 - Default join column name (FK) for @ManyToMany uses owning entity primary table name
Product: [JBoss] JBoss Enterprise Application Platform 6 Reporter: Gail Badner <gbadner>
Component: HibernateAssignee: Gail Badner <gbadner>
Status: CLOSED CURRENTRELEASE QA Contact: Jan Martiska <jmartisk>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4.0CC: cdewolf, jawilson, jmartisk, msimka, smarlow
Target Milestone: CR1   
Target Release: EAP 6.3.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1154212 Environment:
Last Closed: 2019-08-19 12:39:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1154212    
Bug Blocks: 1132166, 1145704    
Attachments:
Description Flags
reproducer none

Description Gail Badner 2014-10-27 11:14:33 UTC
+++ This bug was initially created as a clone of Bug #1154212 +++

Description of problem:


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

--- Additional comment from Gail Badner on 2014-10-17 18:21:27 EDT ---

Description of problem:

The foreign key column name computed for a unidirectional @ManyToMany uses the owner table name instead of the owner entity name.

Version-Release number of selected component (if applicable):

Hibernate core 4.2 and later

How reproducible:
Consistently

Steps to Reproduce:
1. Provide a table name for an entity that differs from the entity name.

@Entity
@Table(name="tbl_city")
public class City {
    @Id
    private Integer id;

    @ManyToMany
    private Set<Item> stolenItems;

    ....
}

Actual results:
Hibernate 4 computes the foreign key column name as tbl_city_id

Expected results:
The foreign key column name should be City_id.

Additional info:
See https://hibernate.atlassian.net/browse/HHH-9390.

Comment 2 Jan Martiska 2014-10-29 14:18:35 UTC
Created attachment 951806 [details]
reproducer

Comment 3 Jan Martiska 2014-10-29 14:21:28 UTC
Partially fixed in Hibernate 4.2.14.SP4-redhat-1 (EAP 6.3.2.CR2).
'Partially' means using Hibernate API directly, not using Entity Manager. Another BZ is coming soon for that scenario.

Attached a reproducer I wrote, should anyone need it.
Note that there is 
configuration.setNamingStrategyDelegator(ImprovedNamingStrategyDelegator.DEFAULT_INSTANCE)
needed in order to activate the fix.