質問

There's a whole lot of beans and vegetables in Java, and it's beginning to confuse me some. I've read a couple of newly published books on Java EE 6, and they all say that "entity beans" has been pruned ("deprecated" would be the correct term for the newcomer not yet brainwashed by the Java framework). The author's are quick to say that they will not at all touch the subject of.. "entity beans". It has been replaced by JPA they say. Then they write a chapter or two about object relationship mapping and annotate the POJO classes with @Entity. They also annotate fields a little bit here and there to specify the mapping configuration when defaults won't suffice.

However, usually when we annotate bean classes, we take that annotation as a type prefix. For example, the annotation @Stateful makes the bean a stateful session bean. Doesn't that mean that the @Entity annotation makes the bean an entity bean - the very thing deprecated they said!?

役に立ちましたか?

解決

@Entity annotated (mapping) classes are not at all related to the 'deprecated' entity beans from the J2EE architectural model. Not really anyway.

Those 'deprecated' entity beans you are reading about are very much still around, just that have been refactored so extensively as to be almost unrecognizable to someone used to old school J2EE.

In the new Java EE model, service and model classes are properly separated, with JPA annotated @Entity beans serving as the models, and @Stateless or @Stateful session beans serving as the service classes.

The key thing to keep in mind is separation of concerns.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top