I've just discovered quite an old piece of code which is directly using a JPA entity in a JSF bean. To me this seems wrong as I've always looked to keep the entity in the back-end/service layer and then created separate objects to use in the front-end/bean.
Nothing is being set on the entity and there's no transaction open, so there's no risk of changing anything, but I'm still concerned that using the getters will query the DB every time as it's all lazily loaded. So I feel it would be better to get the data needed up front and load it into another object.
Having discussed this with some others on my team a few people don't seem concerned about it, but it doesn't seem right to me. I'm hoping someone could give me some information on what is the correct use and why?
Thanks