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

  1. Create new RCP project
    • Create new project for RCP by selecting Plug-in Project
  2. Define a model and a setting file
    • Add required libraries
    • Define a model
    • Define a setting file (persistence.xml)
  3. Create a JPA Entity Editor
  4. Describe ViewID in the Perspective file
  5. Test


Demo

Jalcedo JPA Entity Editor

How to use

1. Create new RCP project

Create new project for RCP by selecting Plug-in Project

  1. File > New > Project...
  2. Select Plug-in Project -> Next
  3. Input Project name -> Next
  4. For the option Rich Client Application. Select Yes -> Next
  5. Select the RCP application with a view template -> Finish


2. Define a model and a setting file

  1. Add required libraries
    • Example
      • DB: Derby
      • O/R mapping tool: Top-link

    • Download libraries
      In the Example, we need the following libraries.
    • Add libraries to the project and set the plug-in classpath.

  2. 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.

  3. 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

  1. Right-click on the entity class and select New > Other...
  2. Select Jalcedo > JPA Entity Editor -> Next
  3. Input Source folder and Package -> Next
  4. Input PersistenceUnit name and select Target Entity -> Finish
    (PersistenceUnit name is the same name as persistence.xml file)
  5. JPA Entity Editor is generated.


4. Describe ViewID in the Perspective file

5. Test