[hibernate-dev] Configuration and custom IdentifierGeneratorFactory implementations

Gunnar Morling gunnar at hibernate.org
Fri Jun 20 08:46:11 EDT 2014


Steve, all,

I would like to work with a custom IdentifierGeneratorFactory which
performs a specific configuration of created generators (basically I want
to pass OGM's GridDialect instead of the original Dialect contract).

Now the problem is that DefaultIdentifierGeneratorFactory is hard-wired in
Configuration, from where it is accessed in the SessionFactoryImpl
constructor. In my particular case the instantiation of Configuration is
not under my control, so I can't sneak in a custom factory via a sub-class.
Interestingly, (Mutable)IdentifierGeneratorFactory is also a service
contract and as such is accessed via the service registry in other places.

My understanding is that Configuration is supposed to go away in ORM 5
anyways, so I'm wondering whether there is a low-effort solution to my
problem as of 4.3.x.

Would it be feasible to add Configuration#setIdentifierGeneratorFactory()
for that purpose? This should help my case; It would require though that
Configuration#mapping is calculated lazily since atm. it captures a
reference to the initially set generator factory.

Any thoughts?

Thanks,

--Gunnar


More information about the hibernate-dev mailing list