Java Archtecture Decision !!
Posted
by santiagobasulto
on Stack Overflow
See other posts from Stack Overflow
or by santiagobasulto
Published on 2010-05-12T03:14:38Z
Indexed on
2010/05/12
3:24 UTC
Read the original article
Hit count: 256
Hi everybody!
I'm developing a medium Java app, and i'm facing a small problem due to my lack of expirience.
I've a custom DAO, which gets "Article" objects from the DataBase. I've the Article class, and the DAO has a method called getArticle(int id), this method returns an Article. The Article has a Category object, and i'm using lazy loading. So, when i request for an Article Category (Article a = new Article(); a.getCategory();) the Article class gets the Category from the DAO and then returns it. I'm now thinking to cache it, so when i request multiple times to an Article's category, the database is only queried one time. My question is: where should i put that cache? I can put it on the Article class (in the DTO), or i can put it on the DAO class.
What do you say?
Thanks!
© Stack Overflow or respective owner