Java / Quarkus Interview questions
What is the difference between Panache Active Record and Repository pattern?
Both patterns provide the same Panache query capabilities, but they differ in where that logic physically lives in the codebase, which affects testability and how naturally the code reads for different team preferences.
// Active Record @Entity public class Person extends PanacheEntity { public String name; public static List<Person> findByName(String name) { return list("name", name); } } // Repository @ApplicationScoped public class PersonRepository implements PanacheRepository<Person> { public List<Person> findByName(String name) { return list("name", name); } }
With Active Record, the entity class itself carries both the data fields and the query/persistence logic, called via static methods directly on the class or instance methods on a loaded object; with Repository, the entity stays a plain data holder, and a separate injectable bean implementing PanacheRepository<T> carries all the query logic instead.
Teams favoring stricter separation of concerns, or wanting to mock data access cleanly in unit tests without touching a static method, generally prefer the Repository pattern; teams prioritizing brevity and a smaller number of classes for simple domains often prefer Active Record, and both can coexist in the same codebase for different entities if needed.
More Related questions...
