Skip to content

Cache Dialect when creating a session factory #1951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2018

Conversation

maca88
Copy link
Contributor

@maca88 maca88 commented Dec 28, 2018

Fixes: #1950

This is a quick fix for the issue as a proper solution would probably require to refactor the logic for creating a session factory.

@fredericDelaporte
Copy link
Member

This fix the session factory building case, but maybe there are other cases which may suffer of re-creating the dialect.
I was thinking about doing something more wide but also a bit more hackish: an internal lazy property on Mapping, but reinitialized on some Configuration method calls like SecondPassCompile.

@maca88
Copy link
Contributor Author

maca88 commented Dec 28, 2018

I've tried to move the Dialect property from IMapping to ISessionFactoryImplementor and the only usage that was problematic is the one from the issue. The IMapping implementation in SessionFactoryImpl uses the dialect from the Settings class that has it stored in a property. The only recreation that I additionally found can happen at:

var result = settingsFactory.BuildSettings(GetDerivedProperties());

Where both BuildSettings and GetDerivedProperties use the Dialect.GetDialect method. As those methods are called only once per session factory I don't think that they are problematic.

@fredericDelaporte
Copy link
Member

Back-ported to 5.2.4.

@maca88 maca88 deleted the GH1950 branch September 27, 2019 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Caching of Property Dialect in class Configuration.Mapping
3 participants