I am working on a project that uses hibernate and spring. Hibernate is encapsulated in a DAO layer and the DAO layer has corresponding service layer as well, theres also the controllers that is mapped for requests and JSP pages. I was told not to pass objects between these layers (Controllers <-> Service <-> DAO) as it is performance overhead. One particular instance was when I needed to update a boolean value in a domain object (ORM class), I wrote a method that passed the domain object between Service layer and DAO layer, and I was told to pass the object ID and the particular boolean value only and to write separate methods in the layers for that. Is this right? I feel doing so will invalidate many advantages of using an ORM tool (Hibernate). Am I wrong to think this? Any advice and insights will be useful….
I am working on a project that uses hibernate and spring. Hibernate is encapsulated
Share
You’re 100% right. That’s terrible advice. Pass the objects around. It’s exactly what Hibernate is designed for, and “performance overhead” for normal passing of objects is just crazy. Unless there’s something about the app that you don’t know, be wary of advice from the person that told you that.