Examples shows rendering of the persistent instances, like this:
public static index() {
Query query = JPA.em().createQuery("select * from Article");
List<Article> articles = query.getResultList();
render(articles);
}
Do I need to do rendering of the persistence objects or I should use DTO pattern before?
public static index() {
Query query = JPA.em().createQuery("select * from Article");
List<ArticlePO> articlesPo = query.getResultList(); // persistence objects...
List<ArticleVO> articlesVo = new ArrayList<ArticleVO>(); // view objects...
for(ArticlePO articlePo : articlesPo) {
ArticleVO articleVo = new ArticleVO();
articleVo.setPropertyOne(articlePo.getPropertyOne);
// and so on
articlesVo.add(articleVo);
}
render(articlesVo);
}
I would be very grateful for the information. Thanks to all.
Aucun commentaire:
Enregistrer un commentaire