Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/326663"

(Config files)
(Config files)
Line 129: Line 129:
  
 
== Config files  ==
 
== Config files  ==
 +
 +
This feature does not require the creation of any new configuration files.  However the user will be responsible for providing the required JAX-RS, JPA, and JAXB config files.
  
 
=== JAX-RS ===
 
=== JAX-RS ===

Revision as of 11:53, 30 September 2010

Design Specification: JPA RESTful Service

ER 326663

Document History

Date Author Version Description & Notes
2010/09/30 Blaise Doughan Initial Version

Project overview

Overview of the project/feature. Why is it desired, what are its goals.

Goals:

  • goal 1
  • goal 2

Concepts

The following example demonstrates how JPA can be used to implement a RESTful web service:

Requirements

The following sections will expand the goals of this project into more concrete requirements.

Design Constraints

Design / Functionality

URI Representation

Data in a RESTful service is referenced through URIs.

Unary Key

Composite Keys

Named Queries

@NamedQuery(name = "findCustomerByName",
            query = "SELECT c " +
                    "FROM Customer c " +
                    "WHERE c.firstName = :firstName AND " +
                    "      c.lastName = :lastName")

Get Single Result:

Get Result List:

REST (CRUD) Operations

POST - Create Operation

@POST
@Consumes(MediaType.APPLICATION_XML)
public void create(Customer customer) {
 entityManager.persist(customer);
}

GET - Read Operation

Get is a read-only operation. It is used to query resources.

@GET
@Produces(MediaType.APPLICATION_XML)
@Path("{id}")
public Customer read(@PathParam("id") long id) {
 return entityManager.find(Customer.class, id);
}

PUT - Update Operation

The put operation updates the underlying resource. When using put the client knows the identity of the resource being updated.

@PUT
@Consumes(MediaType.APPLICATION_XML)
public void update(Customer customer) {
 entityManager.merge(customer);
}

DELETE - Delete Operation

The delete operation is used to remove resources. It is not an error to remove a non-existent resource.

@DELETE
@Path("{id}")
public void delete(@PathParam("id") long id) {
 Customer customer = read(id);
 if (null != customer) {
 entityManager.remove(customer);
 }
}

Testing

API

GUI

Config files

This feature does not require the creation of any new configuration files. However the user will be responsible for providing the required JAX-RS, JPA, and JAXB config files.

JAX-RS

  • The user will need to create the JAX-RS deployment artifacts appropriate to their deployment platform.

JPA

  • The user will need to create the necessary artifacts for JPA

JAXB

  • The user will need to create the necessary artifacts for JAXB
    • jaxb.properties file to specify JAXB implementation
    • eclipselink-oxm.xml as an alternate metadata representation

Documentation

Open Issues

This section lists the open issues that are still pending that must be decided prior to fully implementing this project's requirements.

Issue # Owner Description / Notes

Decisions

This section lists decisions made. These are intended to document the resolution of open issues or constraints added to the project that are important.

Issue # Description / Notes Decision

Future Considerations

During the research for this project the following items were identified as out of scope but are captured here as potential future enhancements. If agreed upon during the review process these should be logged in the bug system.

Back to the top