Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8885551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:20:12+00:00 2026-06-14T21:20:12+00:00

Service facades are usually implemented as stateless session beans, which means that any entities

  • 0

Service facades are usually implemented as stateless session beans, which means that any entities they possibly return will be detached immediately. This makes me think that any entity returned as a result of a service facade business method should eagerly fetch all of its internals, as in the absence of eager fetching, its internals cannot be accessed by service clients. I want to know whether I’m right on this and whether there is possibly any other way which may be more appropriate in certain circumstances.

Thank you

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:20:13+00:00Added an answer on June 14, 2026 at 9:20 pm

    Yes you’re substantially right, entities are detached as soon as they are returned from the session bean method in which they were created or fetched from the database. This means that there is no way, in the client tier, to access lazily loaded related entities.
    From my job experience I can say that there are two common scenarios.
    The first in which the data model in the business tier, implemented with entities and enterprise beans, is completely different from the data model used in the client tier; in this case the best solution is to create so called DTOs (data transfer objects), i.e. plain java objects with get and set methods, and use them for transferring data between the two layers.
    The major drawback of this approach is that writing DTOs could be a long, boring and error prone task and moreover the fact that either they implement no business logic, being pure beans, or the logic must be duplicated in both tiers. This is especially true if the data model in the two tiers is the same and one would reuse behaviour.
    This leads us to the second approach which consists in building a unique data model with entities to be shared in business and client tier, with the obvious advantage of less code writing and logic reuse. However in order to pass the detached entities from one layer to the other you have only two choices: either declare all your relationships as eager, at risk loading too many objects in memory especially if your entities are strongly interconnected, or leave them lazy and write your facade methods carefully in order to load all the needed fields before returning.
    I’ve recently faced a real world project in which the graph of entities connections is almost a complete one, which drove us to prefer lazy loading of relationships, and to avoid writing too many lines of code just to fill the needed related entities of each returned entity in the service facade methods, we resort to DTOs, modelling one of them for each class of client use case and using generic methods to automatically convert entities to the corresponding DTO.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a stateless session bean (the façade) which will be used for managing
<bean id=user class=com.test.service.beans.User scope=session> <aop:scoped-proxy/> </bean> <bean id=userFacade class=com.test.service.facade.UserFacadeImpl init-method=init> <property name=currentUser ref=user/> </bean>
My service communicates with a server that manages accounts. Each Account has a cap
WCF service has one method ( Let's say TestMethod) in which I try to
I'm creating a general purpose web service that is likely to have a number
I am on a project where I will be creating a Web service that
I have a Java enterprise application that provides a web service, has a domain
First,Im running a windows service that should contain a lot of funcionality.There will be
I have an application that is an asmx web service written in .NET 2.0
In the J2EE Pattern Session Façade - that the Core J2EE Patterns - Best

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.