1, the configuration JPA project
JPA is similar to Hibernate persistence specification, it has become part of Java EE 5 specification. JPA controlled using Java 5 annotations ordinary Java classes (POJO) is mapped to a database table.
You can create a JPA project enabled by creating a project basis for any supported type (such as Java or Web project), and then from the MyEclipse add the menu JPA facet to the project. Right-click the item to add JPA facet, and then select MyEclipse> Project Facets> Install JPA Facet from the menu. At the same time, by opening also "Project Facets" attribute item, a plurality of facets simultaneously added to the project.
Provide persistence
MyEclipse provider for OpenJPA, Hibernate and EclipseLink JPA support.
Database Configuration
The project is associated with the database and architecture to support design-time tools. Associated program shown below, and item database-driven MyEclipse Derby local database.
In addition to rely MyEclipse comes with a library, you can also click on the download icon Add user libraries to be included in the project.
Also, you can right-click on the project select "Properties" from the menu, expand MyEclipse> Project Facets, then select Java Persistence, open the Java Persistence properties page at any time to change the association JPA project database driver.
2, from a database reverse engineering entities and DAO
Right-click a JPA project and select "Generate Entities & DAOs" from the menu. You can choose to use MyEclipse reverse engineering tool builder or DALI entity selection, will start the appropriate JPA reverse engineering wizard.
Right-click the table generating entity DB Browser view.
逆向工程过程是完全可定制的。使用JPA逆向工程向导,可以选择要生成的工件以及该工件所基于的数据库表。
MyEclipse还可以生成具有结果分页支持的DAO findBy<property>查询。生成的结果分页API为DAO客户端提供了细粒度的程序控制,可定位到结果集的特定行号并获取n个实体。
以下是逆向工程处理器生成的代码的几个样本片段:
3、高级实体编辑工具
MyEclipse Java持久性透视图
MyEclipse Java Persistence透视图为面向jpa的任务提供了最佳的编辑器和视图布局。
JPA Details视图
通过“JPA Details”视图,可以轻松编辑实体注释。
JPA Diagram编辑器
JPA Diagram编辑器使您可以轻松创建新实体或在现有JPA项目中编辑实体。
JPA Annotation Table和Column Content Assist
JPA Entity Validation
可检测到映射中的错误并在编辑器和“Problems”视图中显示。
可以在项目级别启用或禁用JPA Entity Validator。
4、高级Spring-JPA集成
Spring 2支持
将JPA构面添加到已经具有Spring构面的项目时,您可以选择高级Spring-JPA支持(反之亦然)。这种级别的支持使JPA工具可以与项目的Spring工件一起使用。下图显示了Spring-JPA项目配置向导。
选择Spring-JPA支持,主要bean配置文件,并自定义bean id和事务支持。
逆向工程实体和数据库中的Spring DAO
对于配置为支持高级Spring-JPA功能的项目,除了从数据库架构生成实体类之外,还可以生成与Spring兼容的DAO。在逆向工程过程中,将使用每个DOA类的生成的bean条目更新Spring应用程序上下文文件。
生成Spring DAO:
生成的Spring应用程序上下文文件:
生成的Spring DAO扩展自Spring的JpaDaoSupport: