Quarkus Panache Active Record vs. Repository Pattern

preview_player
Показать описание
When you're using Quarkus Panache, you have the choice between the Active Record and Repository pattern. In this video, I'll compare both approaches and give my opinion and experience on which approach might work better for you.

Рекомендации по теме
Комментарии
Автор

Thank you, Sebastian!
Very inspiring and valuable tutorial.

Would like to suggest you making something with EventBus / Reactive Messaging with Quarkus with SSE (Server-Sent Events) usage. In my opinion, really interesting topic, but there are not enough guides with this stuff. Thanks again!

Liwgfr
Автор

Thanks for the video. I use the active record pattern because to me it make much more sense then the repository pattern and there is also 1 more benefit to the active record that you didnt mention: If you need to use multiple entities in one place you won't need to inject each and every one of them, just use the object as is which less code that is more orginzed.

zrubiz
Автор

I use Active Record pattern. If I'm not mistaken this approach is preferable by the Quarkus team over the repository pattern but your argument makes me want to migrate over to the repository.

omar-zahid
Автор

As someone coming from Rails back to Java after 12 years, Quarkus is a refreshing find. Repository pattern is absolutely ridiculous to me. Entities are inherently tied to a data store so letting them find and persist themselves is not a violation of the often overrated Single Responsibility Pattern. How things are persisted IS domain knowledge. You get more for less with AR pattern and less is always easier to change should the persistence change.

jhirn
Автор

I always use the Active Record pattern because using the Repository pattern will mean for me 2xn classes if I have n entities and I always go for as less classes as I can.

DanielWamara
Автор

Hi Sebastian,
Thanks for the video. Could you please share which applications do you use to record and edit the video?

wenijinew
Автор

It seems to me like using Active record pattern breaks Single Responsibilty Pattern because we're having both database responsibility and entity responsibility in a single Entity class. Or am I missing something here?

vemaiesli
Автор

Awesome video!!! Is there a way to use records instead of classes in the panache active approach?

bmasetto
Автор

I've read the tutorial of Panache a long time ago and I use Quarkus in production...the problem with both approaches is that it only shows how to deal with very very trivial examples where you basically run SELECT * from a single table...yeah it's cool but it's not realistic...in the real world of large databases queries are complex, joining 3-4 tables and very rarely doing SELECT *...very often queries extract only a small subset of fields or maybe fields from different entities joined or even calculated fields like aggregation....How do you do that with Panache repository/active-record? If the answer is JPQL or Criteria query ...hell no... it's just way easier and efficient to write an SQL query.

marcodelpercio
Автор

I prefer Active Record way, But this is a static way. In the TDD you must use a "panache mock". But this way I think is more clear. repository way is another "a long time ago" layer.

MutagenesisConvergente
Автор

One thing that always bothered me is that for example "var coffee = Coffee.findById(id);" would not really work - you'd have to use "var coffee = Coffee.<Coffee>findById(id);" to get the correct type for your coffee variable.

gargarism
join shbcf.ru