The sore point: do we need entities?

Discussions

EJB design: The sore point: do we need entities?

  1. The sore point: do we need entities? (5 messages)

    Can someone give me several strong reasons to use entity beans on a LARGE projects in production. Currently, I cannot see any advantages of using them versus direct JDBC calls from stateless facade - the database transactions could be simply managed by the means of JDBC, the OO structure could be emulated (you can even simply switch to BMP entities when you wish to), special framework is developed to effectively generate DAOs (the development process becomes even faster than creating CMPs), stand-alone caching framework also exists...

    Alex.
  2. In your post you allready listed several reasons for using entity beans: skip writing JDBC code, caching, and create an OO view of data (which, done by hand, is a real sore). You also mentioned how these issues can be solved using mapping frameworks, such as JDO. So I guess you're question really is: "how are entity beans better than other solutions?".
    IMO, the best reason not to use proprietary products is that they make your code less portable and bind you to a specific implementation. This leaves JDO as a possible alternative. I don't think entity beans are better than JDO in just about anything. The only major point you get with entity beans and not with JDO is, AFAIK, automatic handling of relationship semantics. E.g, assignment to one side of a bi-directional relationship changes both, etc. These features can be very usefull when you're modelling an OO view for an *existing* relational model. I don't know if JDO will ever have these features, because they are somewhat incompatible with the normal Java object model, which JDO tries to preserve. If JDO doesn't add these features, I do think entity beans have a little edge as far as modelling an OO view for a relational model is concerned. Otherwise, I can't think of any reason why entity beans are prefferable (maybe App server integration is an advantage for entity beans in the short term, but in long term I don't think it will make a difference).

    Gal
  3. I pretty much use EB to leverage the container's caching benifits, especially for read mostly data. I don't see any other reason for using EB.

    Pranab
  4. Doesn't JDO always load the whole of an object graph when CMP doesn't (if the container supports this)?
  5. Sean,

    I think that lazy-loading depends on a particular JDO implementation as well.

    Alex.
  6. Neither spec dictates the entire object graph should be loaded. In practice I doubt there is any implementation that loads an entire object graph: that's completely impractical and leads to horrible performance.
    Btw, I'm only reffering to EJB2.0 CMP, not EJB1.X. In EJB 1.X there was no concept of relaitonships between different beans, so the question is not relevant.

    Gal