Skip to content

Java Persistance API (JPA)

Project Dependencies

Add the following dependency to your pom.xml/build.gradle file:



Currently the Raynigon Unit API JPA integration only works for hibernate.


To use the Raynigon Unit API with JPA, an Entity needs to be created. This Entity needs to have a @Type annotation with a definition for the QuantityType.


You need to have the @Type annotation on every Entity due to a missing feature in hibernate (see here).

public class BasicEntity {

    public String id;

    public Quantity<Speed> speed;

Depending on the database you are using, you need to specify the columnDefinition property in the @Column annotation. By default, the value stored in the database will be a floating-point value. In this example the value will be saved in "km/h".