Jalcedo JPA Entity Editor Generator
Jalcedo JPA Entity Editor Generator Plug-in is Eclipse plug-in to generate a simple Entity editor using SWT/JFace.
It generates the basic editor that has functions of CRUD (Create, Read, Update, Delete) for the Entity class.
Requirements
Quick Start
- Create new RCP project
- Create new project for RCP by selecting Plug-in Project
- Define a model and a setting file
- Add required libraries
- Define a model
- Define a setting file (persistence.xml)
- Create a JPA Entity Editor
- Describe ViewID in the Perspective file
- Test
Demo
How to use
1. Create new RCP project
Create new project for RCP by selecting Plug-in Project
- File > New > Project...
- Select Plug-in Project -> Next
- Input Project name -> Next
- For the option Rich Client Application. Select Yes -> Next
- Select the RCP application with a view template -> Finish
2. Define a model and a setting file
- Add required libraries
- Example
- DB: Derby
- O/R mapping tool: Top-link
- Download libraries
In the Example, we need the following libraries.- DB: derby.jar (from Apache DB Project)
- O/R mapping tool: toplink-essentials.jar, toplink-essentials-agent.jar (from TopLink JPA Download)
- Add libraries to the project and set the plug-in classpath.
- Example
- Define a model
- Define new Entity class according to the rule of the Java Persistence API and add PropertyChangeSupport.
- Example: Item
@Entity public class Item { @Id private long id; private String name; private int price; public String getName() { return name; } public void setName(String name) { String oldValue = this.name; this.name = name; firePropertyChange("name", oldValue, this.name); } // add getter, setter and ProertyChangeSupport methods. } - Example of Entity class is here.
- Define a setting file (persistence.xml)
- Create META-INF/persistence.xml file under a project.
- Define persistence setting file.
- Example of persistence.xml
please change <persistence-unit> name and <class> (ex. samplepackage.Item)<?xml version="1.0" encoding="UTF-8"?> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"> <persistence-unit name="pu_name" transaction-type="RESOURCE_LOCAL"> <provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider> <class>class_name</class> <properties> <property name="toplink.logging.level" value="FINEST" /> <property name="toplink.target-database" value="Derby" /> <property name="toplink.jdbc.driver" value="org.apache.derby.jdbc.EmbeddedDriver" /> <property name="toplink.jdbc.url" value="jdbc:derby:db/derby/sampledb;create=true" /> <property name="toplink.ddl-generation" value="drop-and-create-tables"/> </properties> </persistence-unit> </persistence> - See also Entity Persistence Support page.
3. Create a JPA Entity Editor
- Right-click on the entity class and select New > Other...
- Select Jalcedo > JPA Entity Editor -> Next
- Input Source folder and Package -> Next
- Input PersistenceUnit name and select Target Entity -> Finish
(PersistenceUnit name is the same name as persistence.xml file) - JPA Entity Editor is generated.
4. Describe ViewID in the Perspective file
- It is the same as JavaBeans Editor Plugin.
5. Test
- It is the same as JavaBeans Editor Plugin.
