[hibernate-dev] 5.0 defaults

Gail Badner gbadner at redhat.com
Tue Aug 4 02:51:30 EDT 2015


I mentioned my concerns about hibernate.implicit_naming_strategy and
auto-quoting keywords when I was getting the standalone TCK working with
master.

Here are my thoughts...

On 08/03/2015 02:17 PM, Steve Ebersole wrote:

> 1) hibernate.implicit_naming_strategy - by default Hibernate uses its
> legacy implicit naming strategy which predates the clarifications made in
> JPA 2.0 by many years.  The question here is whether we want to change
this
> (now/ever) to use the JPA (2.0) compliant one?

IMO, the JPA annnotations should generate tables/columns/etc that are
JPA-compliant by default. If a developer is adding JPA annotations, I think
there is a pretty good likelihood they will be referring to Javadoc or
looking at the annnotations interface itself in an IDE. I think there would
be an expectation that the generated names due to the JPA annotations would
be consistent with what is documented. I think there is also an expectation
that the generated names would be portable.

Here are some examples of bugs I fixed in 4.2/4.3 where generated names
were not consistent with JPA2:
- HHH-9387 (generated table name for @ElementCollection uses entity class
name; should use entity name);
- HHH-9389 (generated join column for @ElementCollection uses entity class
name; should use entity name);
- HHH-9390 (generated foreign key column name for unidirectional
@ManyToMany uses owning entity primary table name; should use owning entity
name.

I agree that 4.2/4.3 was not the proper time to make those changes the
default because it would be a breaking fix that would affect existing
applications.

IMO, 5 is a good place to make JPA-compliant naming the default. It would
still be a breaking change. Existing applications would need to make
necessary changes to either the JPA annotations or to the database objects
themselves to become JPA-compliant (and portable).

>
> 2) hibernate.auto_quote_keyword - by default we decided to have Hibernate
> automatically quote identifiers it thinks are key/reserved words in the
> underlying database.  We know at the moment this is a bit too aggressive
as
> it pulls in all of SQL:2003 defined keywords.  The question is whether we
> disable this by default?

I think it will take some time to get the keyword list right for each
dialect. I wouldn't be surprised if different versions of a DBMS would have
different keywords. This could complicate things as most dialects are used
for multiple versions of a DBMS.

If 5.0.0 is released with auto-quoting as a default, and a later 5.0.x
version excludes keywords, it will be a breaking change for applications
that were developed or migrated to an earlier 5.0 version.

Also, auto-quoting keywords (only) is not JPA-compliant.

I would be more comfortable if auto-quoting keywords is considered
experimental, and not the default behavior.


mailman/listinfo/hibernate-dev
> <https://lists.jboss.org/mailman/listinfo/hibernate-dev>
>


More information about the hibernate-dev mailing list