This repository shows you how to use Java Records as DTO Projections.
public record ShortArticleInfo(String title, String author)
{ }
public List<ShortArticleInfo> fetchAllArticlesInfo(){
return entityManager.createQuery("""
select
new org.jugistanbul.dto.ShortArticleInfo (
a.title,
a.author)
from Article a
""", ShortArticleInfo.class).getResultList();
}
- JDK 15 or later
- Docker(for quarkus dev services)