Top
Interstage Studio User's Guide
FUJITSU Software

4.2.2 Development Flow

Development of applications that use JPA is described below.

  1. Prepare the database
    Prepare the environment for the database to be used with the JPA application.

  2. Create the persistence unit

    • Create a JPA project
      In order to create a JPA application, first create a JPA project. When a JPA project is created as indicated by the wizard, the classpath and other settings required for the build are set automatically.

    • Edit persistence.xml
      Code the data source used by the persistence unit in persistence.xml.

  3. Create the Entity
    Use the following procedures to create the Entity:

    • Create the Entity class
      Use the wizard to create the Entity class.

    • Set the Entity annotation
      Use the JPA Structure view and the JPA Details view to set the Entity annotation in the created class.

    • Set the association with the tables
      Use the JPA Structure view and the JPA Details view to set the associations between the Entity and the database table.

    • Add fields
      Add the fields that are to be the Entity persistence items.

    • Set associations with columns
      Use the JPA Structure view and the JPA Details view to set the associations between persistence fields and the database.

    • Add the get method
      Add the get method to be used to access the persistence fields.

  4. Create the logic class

    • Create the class
      Use the wizard to create a Java class.

    • Implement the logic class
      In the logic class, implement the processing that uses the Entity to access the database.

  5. Create the EAR project
    Create a project for creating an EAR file for distribution as one application including the client. When creating the EAR project, specify to include the created JPA project in the EAR file. Since the client is not yet created, specify to include the client in the EAR file when creating the client project.

  6. Create the Web application
    Use the following procedure to create the Web application that is to be used as the client:

    • Create the dynamic Web project
      Create a dynamic Web project for creating a Web application as a client.

    • Set the build path
      Set the build path for invoking the JPA project logic class from the Web application.

    • Create the servlet class
      Use the wizard to create a servlet as a controller for receiving Web application requests.

    • Specify the Dependency Injection
      An EntityManagerFactory is required because the logic class performs database access processing using an Entity. To fetch this object, specify the Dependency Injection in the field.

    • Implement the servlet class
      Perform implementation processing for the servlet that includes the logic class invocation.

    • Create an I/O page
      Use the wizard to create the Web application I/O page.

  7. Set the Interstage Application Server JDBC
    Use the following procedures to set up the environment so that the data source specified in the persistence unit can be used by a Java EE container.

    • Launch the Interstage Java EE Admin Console
      Launch the Interstage Java EE Admin Console in the Servers view.

    • Create a JDBC Connection Pool
      Use the Interstage Java EE Admin Console to create a JDBC Connection Pool.

    • Create a JDBC Resource
      Use the Interstage Java EE Admin Console to create a JDBC Resource.

    • Set the classpath for the JDBC driver
      Add the JDBC driver to the classpath so that the JDBC driver can be referenced by applications that run in the JavaEE container.

  8. Check the application operation
    Use the following procedure to check the application operation:

    • Associate the project and the server
      Set which server the application is deployed on. Since the applications are archived as an EAR, add the EAR project to the server.

    • Set the breakpoints
      Set the breakpoints for the debugger to check the program operation during execution.

    • Launch the server
      Launch the server so that it can receive requests in relation to the application from Web browsers. Deployment is performed automatically before the server starts.

    • Execute the application
      Launch the Web browser and access the application URL to start checking the operation of the application.

    • Debug the application
      Debug the program and check that the application is operating correctly.

  9. Distribute the application to the operating environment
    Use the following procedures to distribute the application to the operating environment:

    • Export the application
      Create an EAR file to distribute the application to the operating environment.

    • Distribute the application to the operating environment
      Deploy the EAR file from the Interstage Java EE Admin Console.