A simple JPA backend service that loads data from a CSV file and make it accessible through Person
entity.
It can be easily upgraded to read/write from a real database instead of the CSV file.
You can modify the provided demo data from Persons.csv
located under src/resources
.
After installing this project locally, you can reference it by including it as a dependency into the front-end project. Most probably you will need to include JavaEE dependencies as well:
<dependencies>
...
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.vaadin.stepbystep</groupId>
<artifactId>person-service</artifactId>
<version>2.0</version>
</dependency>
...
</dependencies>
- Inject
PersonService
. - Call
getEntries()
to return a list ofPerson
. - Call
delete()
orsave()
to update a given entity. - Call
getFirst()
to retrieve the first entity. - Call
getById()
to retrieve an entity by its id.
@Inject
PersonService service;
void load() {
component.bind(service.getEntries());
}
You can obtain the maven dependency from Vaadin Directory without any downloads or installs.
Platform and IDE independent, you can install this project locally using the following three commands:
$ git clone git@github.com:amahdy/person-service.git
$ cd person-service
$ mvn install
Instructions on how to import using Eclipse are available in the eclipse branch.