[hibernate-dev] Naming strategies 4.3 -> 5.0

Steve Ebersole steve at hibernate.org
Sat Aug 15 10:25:07 EDT 2015


I think I may have goofed when I implemented some of the
ImplicitNamingStrategy rules in 5.0.

During that transition, I wrote a bunch of unit test in 4.3 to serve as a
baseline to make sure I got the logic/rules right as I developed 5.0.  But
I think I may have set up those initial 4.3 tests improperly.
Specifically, there are a few meant to test Hibernate's legacy naming
behavior, aka its non-JPA-compliant naming.

I think I got confused by the whole concept of NamingStrategy and
NamingStrategyDelegate and NamingStrategyDelegator that had gotten added to
4.3.

So on 4.3, what is the proper way to specify Hibernate should use
JPA-compliant implicit naming?  What is the proper way to specify that it
should use its legacy naming?

The issue came to light via HHH-9908.  Consider a mapping like:

@Entity
@Table(name = "ptx")
public class Ptx {

    @Id
    private Integer id;

    @ManyToMany
    private List<Input> inputs1;

}


Assuming that Inputs defines its primary table as "input", the
JPA-compliant naming would be "ptx_input".  That is what happens on 4.3
using EJB3NamingStrategy.  It is actually also what happens on master using
ImplicitNamingStrategyJpaCompliantImpl.

However, the "legacy" part I cannot figure out.  Unless I misremember, back
in the day we used to interpret these based on the attribute name, rather
than the associated table name.  So here we'd have "ptx_inputs1".  That is
in fact what ImprovedNamingStrategy does on 4.3.  But I
believe ImprovedNamingStrategy is not the default on 4.3.  Again, between
NamingStrategy and NamingStrategyDelegate and NamingStrategyDelegator it is
VERY hard to understand what it going on, so maybe I just missed
something.  Anyway, on 4.3 setting no naming strategy forces this to behave
in a JPA-compliant way, meaning the implicit name here is "ptx_input" when
I do not specify anything for NamingStrategy(Delegat(e/or)).  So either
that got screwed up in 4.2/4.3 (whenever those new indirections where
added) or I simply misremember what we used to do here.


More information about the hibernate-dev mailing list