简体   繁体   English

Eclipse中的JPA项目和EJB项目有什么区别?

[英]What is difference between JPA Project and EJB Project in Eclipse?

Which one is used when?什么时候用哪一个?

When I want JSF + Stateless Bean + JPA Entity application I need EJB Project and Dynamic Web Project integrates in EAR Project?当我想要 JSF + 无状态 Bean + JPA 实体应用程序时,我需要 EJB 项目和动态 Web 项目集成在 EAR 项目中?

An EJB project is a project focused on the development of Enterprise Java Beans.一个EJB项目是一个专注于企业Java Beans开发的项目。 Commonly, EJBs depend on Entitity Beans for persistence which are implemented using the JPA technology (think of JPA as a dependency of the EJB).通常,EJB 依赖于实体 Bean 来实现持久性,这些实体 Bean 是使用 JPA 技术实现的(将 JPA 视为 EJB 的依赖项)。

The reason that you have the option to create a JPA project independently of the EJB, is that some people might not want to use (or don't need to) EJBs but still, they need to use an ORM framework such as JPA.您可以选择独立于 EJB 创建 JPA 项目的原因是,有些人可能不想使用(或不需要)EJB,但他们仍然需要使用 Z8B8A92C27C103F10168D764DD7969DD9CZ 框架,例如 ZA9074D1BD88935C51 Such case could be for instance a web project (ie JSF) that would use JPA directly for persistence (no EJBs).例如,这种情况可能是 web 项目(即 JSF),该项目将直接使用 JPA 进行持久性(无 EJB)。

The takeaway point is that although EJB 3 used JPA for persistence, you don't have to necessarily use EJBs in your project (unless you need to do so) in order to benefit from an ORM framework such as JPA.要点是,尽管 EJB 3 使用 JPA 进行持久性,但您不必在项目中使用 EJB(除非您需要这样做)才能从 ORM 框架(例如 ZA807CC44088935905016)中受益。

Now, to enable JPA on an EJB project in eclipse right-click on the project, go to "Project Facets" option and select the JPA facet. Now, to enable JPA on an EJB project in eclipse right-click on the project, go to "Project Facets" option and select the JPA facet. By doing so, eclipse will add the required libraries, create the necessary artifacts (persistence.xml) and enable the JPA related tooling on your IDE.通过这样做,eclipse 将添加所需的库,创建必要的工件 (persistence.xml) 并在 IDE 上启用 JPA 相关工具。

The Java Persistence API, sometimes referred to as JPA, is a Java programming language specification which describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition. The Java Persistence API, sometimes referred to as JPA, is a Java programming language specification which describes the management of relational data in applications using Java Platform, Standard Edition and Java Platform, Enterprise Edition.

The Java Persistence API originated as part of the work of the JSR 220 Expert Group. Java 持久性 API 起源于 JSR 220 专家组的工作。 JPA 2.0 is the work of the JSR 317 Expert Group. JPA 2.0 是 JSR 317 专家组的工作。

Persistence in this context covers three areas:在这方面的持久性包括三个方面:

the API itself, defined in the javax.persistence package
the Java Persistence Query Language (JPQL)
object/relational metadata

Enterprise JavaBeans (EJB) is a Java API developed by Sun Microsystems that defines a component architecture for multi-tier client/server systems. Enterprise JavaBeans (EJB) 是由 Sun Microsystems 开发的 Java API,它定义了多层客户端/服务器系统的组件架构。

EJB systems allow developers to focus on the actual business architecture of the model, rather than worry about endless amounts of programming and coding needed to connect all the working parts. EJB 系统允许开发人员专注于 model 的实际业务架构,而不用担心连接所有工作部件所需的无穷无尽的编程和编码。 This task is left to EJB server vendors.此任务留给 EJB 服务器供应商。 Developers just design (or purchase) the needed EJB components and arrange them on the server.开发人员只需设计(或购买)所需的 EJB 组件并将它们安排在服务器上。

Because EJB systems are written in Java, they are platform independent.因为 EJB 系统是用 Java 编写的,所以它们是平台无关的。 Being object oriented, they can be implemented into existed systems with little or no recompiling and configuring.面向 object,它们可以在现有系统中实现,只需很少或不需要重新编译和配置。

It depends on the version of Java EE you are using.这取决于您使用的 Java EE 的版本。 In Java EE 6 we can have the EJBs in the WAR file itself.在 Java EE 6 中,我们可以在 WAR 文件本身中包含 EJB。 So one Dynamic web project would suffice.因此,一个 Dynamic web 项目就足够了。

If you are using Java EE 1.5 then you need to have a Dynamic Web project for JSF and for Stateless bean you need to have an EJB Project and also an enterprise project is need to bundle the WAR and JAR into an EAR. If you are using Java EE 1.5 then you need to have a Dynamic Web project for JSF and for Stateless bean you need to have an EJB Project and also an enterprise project is need to bundle the WAR and JAR into an EAR. You can have persistence related classes in EJB project itself and dont require a JPA project here.您可以在 EJB 项目本身中拥有与持久性相关的类,并且此处不需要 JPA 项目。

Java EE provides the facility to make use of JPA independent of EJBs so if your application does not require EJBs but still want to make use of JPA then you can go for a JPA project. Java EE provides the facility to make use of JPA independent of EJBs so if your application does not require EJBs but still want to make use of JPA then you can go for a JPA project.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 eclipse中刷新和更新项目有什么区别 - what is the difference between refresh and update project in eclipse Eclipse中的“ Java Project”和“ Project”选项有什么区别? - What is the difference between the “Java Project” and “Project” options in Eclipse? JPA是否应成为Eclipse Enterprise Project中EJB模块和/或Web模块的一部分? - Should JPA be part of EJB Module and/or Web Module in a Eclipse Enterprise Project? eclipse中的两个不同项目:EAR项目中的(JPA和EJB)(CDI问题) - Two differents projects in eclipse: (JPA & EJB) in a EAR Project (problems with CDI) 企业应用程序项目和EJB项目之间有什么区别? - Whats the difference between an Enterprise Application Project and an EJB Project? `Eclipse / Project / Clean ...`和`Eclipse / Project / Refresh(F5)`有什么区别? - What's the difference between `Eclipse/Project/Clean…` and `Eclipse/Project/Refresh (F5)`? Maven项目与Eclipse中其他项目之间的区别 - Difference between maven project and other projects in Eclipse 如何在EAR项目中部署EJB项目和JPA项目 - How to deploy EJB project and JPA project in EAR project Eclipse动态Web项目IDE中的“Java Build Path”和“Deployment assembly”有什么区别? - What is the difference between “Java Build Path” and “Deployment assembly” in Eclipse dynamic web project IDE? 在任何java项目的eclipse构建路径中,项目和库之间有什么区别 - what is the difference between projects and libraries in eclipse's build path for any java project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM