java-design-patterns icon indicating copy to clipboard operation
java-design-patterns copied to clipboard

DAO Factory pattern

Open iluwatar opened this issue 4 years ago • 18 comments

Description: The DAO (Data Access Object) Factory design pattern is used to abstract and encapsulate all access to the data source, providing a clean separation between the business logic and the data access logic. This pattern enables the application to switch between different data sources and provides a mechanism to manage the data access objects efficiently.

Main elements of the pattern:

  • DAO Interface: Defines the standard operations to be performed on a model object(s).
  • Concrete DAO Class: Implements the DAO interface and handles the CRUD operations with the data source.
  • DAO Factory Interface: Provides a way to get the appropriate DAO based on the data source.
  • Concrete DAO Factory Class: Implements the DAO Factory interface and returns instances of the specific DAO.

References:

  1. DAO Factory Design Pattern - Oracle
  2. Java Design Patterns - DAO

Acceptance Criteria:

  1. Implement the DAO interface and at least one concrete DAO class for a model object.
  2. Create a DAO Factory interface and a concrete implementation of the DAO Factory that returns instances of the concrete DAO.
  3. Ensure that the implementation is well-documented and includes unit tests for the DAO methods and factory.

iluwatar avatar Jul 07 '20 16:07 iluwatar

Hi, I would like to work on this issue. Can you assign it to me?

ilhan-mstf avatar Oct 10 '20 09:10 ilhan-mstf

Ok @ilhan-mstf

iluwatar avatar Nov 07 '20 17:11 iluwatar

@ilhan-mstf are you still working on this issue? Thanks.

NatalieSty avatar Oct 14 '21 20:10 NatalieSty

not actually, sorry

ilhan-mstf avatar Oct 15 '21 06:10 ilhan-mstf

@iluwatar I'd like to work on this issue, can you assign it to me? Thanks!

NatalieSty avatar Oct 16 '21 18:10 NatalieSty

Ok @NatalieSty

iluwatar avatar Oct 19 '21 17:10 iluwatar

Which databases should this factory support? Just the ones listed in the document, or others like mySQL or MSSQL?

AlexTamulaitis avatar Nov 02 '21 23:11 AlexTamulaitis

@iluwatar I am working on it with AlexTamulaitis. Can you advise which database should this factory support? Thanks!!

NatalieSty avatar Nov 04 '21 04:11 NatalieSty

Let's say we need 3 different storages: relational database (e.g. HyperSQL in-memory database), document database (e.g. Mongo), and flat file. @NatalieSty

iluwatar avatar Nov 10 '21 19:11 iluwatar

@iluwatar we are almost done implementing using mySQL and Derby. Can we support two relational database and one document database?

NatalieSty avatar Nov 11 '21 02:11 NatalieSty

Yeah, it's a good start

iluwatar avatar Nov 11 '21 17:11 iluwatar

@iluwatar We went into some hiccups with mySQL; it seems like mysql is no longer supported by SonarQube, and it would be the same for the cloud version. even if it still supports it, it might require the you to install it and create a sonar user with permissions: https://docs.sonarqube.org/7.4/setup/install-server/.

Is derby DB enough for demonstrating this Factory supports relational database? Can we fulfill this issue requirement with just supporting Derby and Mongo?

NatalieSty avatar Nov 22 '21 07:11 NatalieSty

Yes, it's good enough for now @NatalieSty

iluwatar avatar Nov 28 '21 07:11 iluwatar

@iluwatar Do you want us to include the mySQL code in the pull request and raise another issue to try to get it to run on Sonar? We can comment it out to avoid errors.

NatalieSty avatar Dec 01 '21 02:12 NatalieSty

I'm not sure that I understand the issue you are having with MySQL and SonarQube. Are you trying to install SonarQube for yourself to scan the code?

iluwatar avatar Dec 11 '21 14:12 iluwatar

Hi @iluwatar, I am interested and would like to give this issue a try. Can you assign it to me? Thanks!

rrreynaldo avatar Oct 08 '22 00:10 rrreynaldo

Ok @rrreynaldo

iluwatar avatar Oct 08 '22 10:10 iluwatar

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Nov 28 '22 14:11 stale[bot]