Cannot set PhysicalNamingStrategy from properties

Description

Hello Hibernate team,

it does not seem possible to easily set up a PhysicalNamingStrategy from a property files.
I am in a Spring environment, so the following occurs.

  1. A configuration instance is created (from org.hibernate.cfg.Configuration#Configuration(org.hibernate.boot.registry.BootstrapServiceRegistry))

  2. the Session factory is built through org.hibernate.cfg.Configuration#buildSessionFactory(org.hibernate.service.ServiceRegistry)

In that context, all information regarding regarding PhysicalNamingStrategy are correctly extracted from the service registry, while creating the metadataBuilder.

However, it then hits the line testing if physicalNamingStrategy is already defined in Configuration instance. As all constructor calls #reset(), that sets physicalNamingStrategy to PhysicalNamingStrategyStandardImpl.INSTANCE, it is never null, and client configuration previously set is always overridden.

Regards

Environment

None

Activity

Show:
Thomas Mayer
June 22, 2017, 6:28 AM
Edited

I can confirm this issue against 5.2.10.Final. I do configuration using a hibernate.cfg.xml which works in principle (application connects to database, so hibernate reads the configuration at least).

I tried to override methods from PhysicalNamingStrategyStandardImpl via hibernate.cfg.xml with

Using a step debugger, I figured out hibernate still uses PhysicalNamingStrategyStandardImpl because its methods were executed whereas the overriding methods were not.

Hibernate also reads the configuration variables in principle and tries to use them for a naming strategy (When I intentionally do something wrong, Hibernate tells me that something goes wrong with the strategy).

Assignee

Unassigned

Reporter

Olivier Peyrusse

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Minor
Configure