RESTful JPA One-liners With Rapidoid

ICYMI: Let’s see how easy it is to implement RESTful services with simple JPA CRUD functionality with Rapidoid, the almighty web framework.

Bootstrapping JPA and Implementing RESTful Services

import org.rapidoid.jpa.JPA; import org.rapidoid.setup.App; import org.rapidoid.setup.On; public class JPADemo { public static void main(String[] args) { App.run(args).jpa(); // bootstrap JPA On.get(“/books”).json(() -> JPA.of(Book.class).all()); On.get(“/books/{id}”).json((Long id) -> JPA.get(Book.class, id)); On.post(“/books”).json((Book b) -> JPA.insert(b)); On.put(“/books/{id}”).json((Book b) -> JPA.update(b)); } }

Of course, we also need some JPA entity (which is over-simplified for this demonstration): https://goo.gl/iadmcG #DataIntegration #ML

Subscribe To Newsletter

Sign up for my newsletter and get the latest technology news

2019 © Craig Brown PhD. All rights reserved.