Skip to content

NH-3978 - Extract IDatabaseMetadata from DatabaseMetadata #537

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 2 commits into from
Apr 6, 2017

Conversation

CodeWithCream
Copy link
Contributor

@CodeWithCream CodeWithCream commented Dec 4, 2016

Extracting IDatabaseMetadata from DatabaseMetadata

https://nhibernate.jira.com/browse/NH-3978

@oskarb
Copy link
Member

oskarb commented Dec 4, 2016

Hi,

Is there an issue in Jira?
What's the motivation for this?
Other changes have been done in Hibernate, which doesn't even have this file since March 2015. Might be useful to look into if those changes can be ported.

@CodeWithCream
Copy link
Contributor Author

CodeWithCream commented Dec 5, 2016

Hi Oscar,
no there is no JIRA issue for this change. My motivation for doing this is a little bit selfish ;) but I think it can help others too...
About 2 years ago we made a custom implementation of upgrading database schema because we didn't want to depend on database connection. Our solution uses an old model .dll and mapping xml and a new model .dll and using the nhibernate implementation for generating update scripts we generate them without connecting to the database because we have migrations (with fluent migrator) and we cannot generate database upgrade script only between current and the last version because some migrations could use columns and tables that doesn't exist anymore. So we decided to make update scripts for each model change and when we upgrade the database we execute that scripts one by one combining them with the migration of the same version.
To do that we had to download nhibernate source code and make our own CustomDatabaseMetadata implementation so we can fill its data manually after getting them from the mapping file. I looked at the code and realized that the only thing I have to change is extracting IDatabaseMetadata from DatabaseMetadata and change the implementation of the GenerateSchemaUpdateScript so that it uses interface instead of the concrete class because scripts generation doesn't care of how DatabaseMetadata was filled.
I taught that maybe more people would like to have their custom utilities without having to maintain their own nhibernate source (we had a problem when we had to upgrade to nhibernate 4 because we had to implement it one more time) and I saw that ITableMetadata was already extracted so I decided to change a code a little bit because it means a lot and don't change a main implementation at all.

I can show you our update script generator implementation (I have a plan to write a blog post about it because I thing it's a really great thing) but I'll have to simplify it a little bit or show you only an important part of the whole solution...

Can you explain a little bit what your last sentence means? I've only worked with nhibernate, so I don't know a Hibernate code...

@fredericDelaporte
Copy link
Member

fredericDelaporte commented Mar 30, 2017

NHibernate is a fork from Hibernate and a lot of its code is ported from Hibernate. The corresponding Hibernate file for DatabaseMetaData was removed in this commit. Prior to that removal, it had received changes which were not ported to NHibernate. Its latest version is here. Maybe there was other interesting things to port from it. As you look quite involved in using those features, it may be of interest to you.

We need a Jira for tracking changes and managing our releases. Could you please add one?
https://nhibernate.jira.com

@hazzik hazzik changed the title Extracting IDatabaseMetadata from DatabaseMetadata NH-3978 - Extracting IDatabaseMetadata from DatabaseMetadata Apr 6, 2017
@hazzik hazzik changed the title NH-3978 - Extracting IDatabaseMetadata from DatabaseMetadata NH-3978 - Extract IDatabaseMetadata from DatabaseMetadata Apr 6, 2017
@hazzik
Copy link
Member

hazzik commented Apr 6, 2017

I created a JIRA. NH-3978

@hazzik hazzik removed the Need JIRA label Apr 6, 2017
@hazzik hazzik merged commit e61db9e into nhibernate:master Apr 6, 2017
@fredericDelaporte fredericDelaporte added this to the 5.0.0 milestone Apr 6, 2017
@hazzik hazzik added the r: Fixed label Aug 3, 2017
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.

4 participants