iluwatar / java-design-patterns

Design patterns implemented in Java
https://java-design-patterns.com
Other
89.99k stars 26.6k forks source link

Active Record pattern #79

Open iluwatar opened 9 years ago

iluwatar commented 9 years ago

Description

The Active Record design pattern is a common architectural pattern used to manage database records. It simplifies data access by encapsulating the database logic within a model class. Each instance of the model corresponds to a row in the database, and the model class includes methods for CRUD (Create, Read, Update, Delete) operations.

Main Elements of Active Record Pattern:

  1. Model Class: Represents a table in the database. Each instance represents a single row.
  2. CRUD Operations: Methods for Create, Read, Update, and Delete operations are defined within the model.
  3. Database Connection: The model class manages the database connection.
  4. Simple Queries: Basic querying capabilities are encapsulated within the model.

References

Acceptance Criteria

  1. A new model class should be created, representing a database table.
  2. The model class should include methods for basic CRUD operations.
  3. The implementation should adhere to the project’s contribution guidelines and include relevant documentation and unit tests.
stephen-lazarionok commented 9 years ago

I may help with implementing this pattern. Please let me know if it's oaky with you.

iluwatar commented 9 years ago

Sure, go ahead, your contribution is welcome!

stephen-lazarionok commented 9 years ago

Okay, I will work on this pattern

stephen-lazarionok commented 9 years ago

Pull request #206 is prepared. Please review.

stephen-lazarionok commented 9 years ago

I've fixed the points raised and left my comments

iluwatar commented 8 years ago

jOOQ uses Active Record pattern: http://www.jooq.org/

iluwatar commented 4 years ago

Described in book "Patterns of Enterprise Application Architecture" by Fowler

iluwatar commented 4 years ago

https://www.vertabelo.com/blog/orms-under-the-hood/

TwentyVentti commented 2 years ago

@iluwatar I can help work on this pattern let me know if that’s okay with you.

iluwatar commented 2 years ago

Nice, please go ahead @TwentyVentti

TwentyVentti commented 2 years ago

Sorry I accidentally created a pull request to this repo instead of my fork. I will send an intentional pull request tomorrow.

stale[bot] commented 1 year ago

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] commented 1 year ago

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

iluwatar commented 7 months ago

I'll assign to you @sergejsvisockis

sergejsvisockis commented 7 months ago

Hi @iluwatar ,

Thank you for assigning! However, I have unassigned myself from the issue. Taking into consideration my limited availability within the open source community at the moment I would like to take more deliberate steps in these regards and implement this one at the nearest convenience.

If there are no time limitations then feel free to assign it back to me in any case I keep this issue in the loop on my tasks.

Thank you!

iluwatar commented 5 months ago

Updated task description

ipaulaandreea commented 1 month ago

@iluwatar Can you assign me with this task, please?