Skip to content

Conversation

@daus-salar
Copy link

Hallo Moritz,

my company http://www.carneios.de had also the idea to create a time tracking app like trackr.
After some evaluation we considered a very similar tech stack, but did not start development yet. Also we currently evaluate to use trackr or patch it to our needs, we had created some prototypes.
During this creation of prototypes, we solved some problems using jsr310(java date time api).

In this branch I want to show you our solution by migrating trackr to jsr310. Although I can't test it with the front end since I haven't tried to start an oauth service up to now, all unit tests succeed.

Here a summary of the changes

  • Since JPA 2.1 there exists the concept of an converter, see http://docs.oracle.com/javaee/7/api/javax/persistence/Converter.html. Actually it is rather simple to implement, see package de.techdev.trackr.domain.converter;. With the autoApply option you even get rid of any special annotations on date-time fields.
  • To replace the old Date objects I used the following rules:
    ** Date fields annotated with @Temporal(DATE) are converted to fields of type LocalDate
    ** Date fields annotated with @Temporal(TIME) are converted to fields of type LocalTime
    ** Date fields annotated with @Temporal(TIMESTAMP) are converted to fields of type Instant
  • To provide a proper json serialization I wrote custom module, see TimePropertiesToJson
  • For the the http parameter mapping I copied your DateConverter. At this point I am not sure whether there is no time ("hh:mm") http parameter in your application, since I haven't write one but all tests pass.

Possible breakage with frontend:

  • In ReportResourceTest.java,TravelExpenseResourceTest.java, VacationRequestResourceTest.java you used new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); to write the test data to the backend. Unfortunately this isn't compatible with the DateTimeFormatter.ISO_INSTANT since the utc sign 'Z' is missing. I don't think this is really a problem but you should know this.

At the end I conclude it is not difficult to and definitely not impossible to use jsr 310 with jpa and spring. But I can agree that a little bit more support by Hibernate and Spring is desirable.

Regards Lars

@alexgutjahr
Copy link

Hi Lars,

this is awesome! When we decided to open-source trackr we hoped that it will be of good use to others who chose a similar stack. So we are really happy to see your enhancements.

Currently we slowed down development but will pick it up again soon.

So please keep us in the loop and let us know if we can be of any help or if you want to share your experiences!

Cheers,
Alex

@FrontierPsychiatrist
Copy link
Contributor

Thanks Lars, this is great! I will test it out with our frontend and look forward to merge it. The constant conversions between java.util.Date and LocalDate are really cumbersome.

As Alex said, if you have any further questions please contact us!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants