Skip to content
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

To inverse dependencies of Dao #2378

Merged
merged 3 commits into from Sep 26, 2023
Merged

Conversation

tesshucom
Copy link
Owner

@tesshucom tesshucom commented Sep 25, 2023

Overview

Dao dependencies will be improved. There is no immediate impact on current functionality. That's required for future modifications.

Goal

Preparation for future modifications. Arrangements will be made so that some SQLs can be automatically switched to dedicated SQLs in a specific DB. Mainly to speed up scanning.

Non-Goal

This pull request does not include query rewriting. Change only the mechanism without changing the existing processing.

Details

Broadly speaking, there are three fixes related to Dao dependencies.

  • Change to inverse AbstractDao dependencies
  • Split dao package into three packages
  • Add dialect to switch part of Mediafile for each DB

Change to inverse AbstractDao dependencies

It used to be like this:

image

Abstract classes are deprecated in favor of dependency injection. The class name will be changed to TemplateWrapper.

image

Split dao package into three packages

This is not required, but the package will be split. There are advantages to both splitting and not splitting. The advantage of splitting is that it is easy to understand.

  • base : Contains Helper, Utils, and Wrapper classes. Many are directly related to Spring or Liquibase.
  • dialect : Newly created package related to DB dialect. Spring's dialect is not enough. Alternatively, gimmicks for "clever" SQL partial switching will often introduce complexity. Therefore, It is assumed that the entire Dao method (a series of SQL processing) will be rewritten. Some Dao will work by injecting the module class here.
  • dao : Traditional Dao. Ideally, your Service classes should only access this package.

image

Add dialect to switch part of MediafileDao for each DB

For example, MediafileDao looks like this:

image

There are about 12 methods extracted in DialectMediaFileDao. There is a high possibility that speeding up these queries can be expected by replacing them with queries that are highly dependent on the DB grammar.

  • Processing that has already been implemented has been moved to AnsiMediaFileDao. An equivalent method exists in HsqlDBMediaFileDao, but Ansi delegate is used internally now.
    • If the profile at startup is HOST -> HsqlDBMediaFileDao
    • If the profile at startup is URL, JNDI-> AnsiMediaFileDao
    • In other words, the queries executed are the same, only the processing path is different, now.
  • From now on, all we need to do is write a query optimized for HSQLDB in HsqlDBMediaFileDao.

 - AbstractDao class name is changed to TemplateWrapper
 - All Dao use TemplateWrapper
 - Helper, Utils, Wrapper are moved to dao.base package
 - Extract methods that can improve speed by rewriting optimal queries
   for a specific DB.
@tesshucom tesshucom added in: data Issues in data (jdbc, db, dao, liquibase) type: hotfix Should be in patch release instead of next version release type: maintenance Refactorings not related to logic, etc. labels Sep 25, 2023
@tesshucom tesshucom added this to the jpsonic 113.0.0 milestone Sep 25, 2023
@tesshucom tesshucom self-assigned this Sep 25, 2023
@tesshucom tesshucom merged commit d07577f into hotfix Sep 26, 2023
3 checks passed
@tesshucom tesshucom deleted the hotfixes/dependency-inversion branch September 26, 2023 04:08
@tesshucom tesshucom mentioned this pull request Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: data Issues in data (jdbc, db, dao, liquibase) type: hotfix Should be in patch release instead of next version release type: maintenance Refactorings not related to logic, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant