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

Implement persistence with Panache and H2 #22

Merged
merged 5 commits into from
Aug 30, 2024
Merged

Implement persistence with Panache and H2 #22

merged 5 commits into from
Aug 30, 2024

Conversation

ueberfuhr
Copy link
Contributor

@ueberfuhr ueberfuhr commented Aug 30, 2024

Weiterführende Informationen

  • H2-Console aktivieren - leider sehr umständlich und nicht trivial für Produktion abschaltbar - daher hier nicht eingebaut
  • Beispiel für JPA Entities mit Relationen - Achtung: Spring Boot Projekt
  • Fallstricke bei JPA:
    • Mapping von Enums (siehe Introduce customer state converter ralf-ueberfuhr-ars/quarkus-2024-06-17#20)
    • 1:n/m:n-Beziehungen werden Lazy (bei Aufruf des Getters) geladen, falls nicht explizit per FetchType anders angegeben
      • Vorsicht bei hashCode()/equals()/toString(), v.a. wenn von Lombok generiert - dann per Lombok-Annotation ausschließen
      • Vorsicht bei MapStruct-Mappern
    • 1:1/n:1-Beziehungen werden Eager (sofort) geladen, falls nicht explizit per FetchType anders angegeben
      Vorsicht bei großen Daten (CLOBs, BLOBs)

Active Record vs. Repository

Active Record

  • Pros: Simplicity, quick development, easy to understand.
  • Cons: Tightly coupled to the database, less testable, can lead to fat models with mixed responsibilities.
  • Use when: The application is simple, needs quick prototyping, or when tight coupling with the database is acceptable.

Repository

  • Pros: Decouples domain and persistence logic, better testability, more flexible, fits well with complex business logic.
  • Cons: More complex, requires more boilerplate, might be overkill for simple applications.
  • Use when: The application has complex domain logic, needs to be testable, or when decoupling from the database is important.

@ueberfuhr ueberfuhr merged commit a73d874 into main Aug 30, 2024
1 check passed
@ueberfuhr ueberfuhr deleted the feature/db branch August 30, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant