+++ 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.
Created attachment 951806 [details] reproducer
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.