gene wrote:gene wrote:During the next weeks, I will publish this new "dropwizard seed" project to Github and will do a blog post about this.
A first version of the generic server project is
online at github.
Feels good!
Today I published a new feature to the generic server aplication - and will try to add this also to the Oregami server application soon!
I added the support for basic version control with Hibernate Envers.
So if you change an existing entity, Envers automatically saves the old state of that entity. Then you can e.g. ask the database for the revisions of a single entity or you can load the concrete older revisions.
Some general information about Hibernate Envers can be found
here, the full developer documentation is
here.
The most annoying thing I encountered was that I got some weird ClassCastExceptions when I asked Envers for the revisions of an entity. It turned out that dropwizard included an older version of Javassist than the version that Hibernate Envers needs.
So I had to do this in the pom.xml:
Code: Select all <dependency>
<groupId>com.hubspot.dropwizard</groupId>
<artifactId>dropwizard-guice</artifactId>
<version>${dropwizard.version}</version>
<exclusions>
<!-- javassist used here is too old and must be excluded!
See http://stackoverflow.com/questions/23215917/javassist-classcastexception-in-hibernate-and-netbeans
-->
<exclusion>
<artifactId>javassist</artifactId>
<groupId>javassist</groupId>
</exclusion>
</exclusions>
</dependency>
Ugly!
Another more interesting question was how to expose older revisions of an entity via the REST API.
I decided to do it this way:
Show a single task with:
Code: Select all GET => http://localhost:8080/task/[id]
List all revision numbers of a task with:
Code: Select all GET => http://localhost:8080/task/[id]/revisions
Returns [1,2] if an entity has the two revisions 1 and 2.
Show a special revision of a single task with:
Code: Select all GET => http://localhost:8080/task/[id]/revisions/[revisionNumber]
What do you think about this?