4

I am considering to break up my relationship with Hibernate right at the beginning so no one gets hurt and switch to JOOQ for various reasons [1],[2],[3] et. al.

But first I'd like to know a few basic things e.g. how to have Pattern-Constraints on a String like this in Hibernate:

@NotEmpty(message = "Firstname cannot be empty")
@Pattern(regexp = "^[a-zA-Z0-9_]*$", message = "First Name can only contain characters.")
private String firstname;

or if modifying the JOOQ code generator is a big pain or rather straight forward if I want for example to use joda-time on my backend.

What is about caching? I know that JOOQ does have support for e.g. reusing statements but unfortunately I don't know if I would have to look for a third-party library that will do more sophisticated caching for me or if JOOQ is already capable of doing all this for me.

Maybe someone could give me a scratch about how I could get started with a bigger application. As for now my workflow would look as such:

  1. Write my database in MySQL by hand
  2. Use FlywayDB for migration-versioning and deploy the database to Tomcat
  3. Reverse engineer the database with JOOQ to generate Java files
    • Is this where my code generator extension will e.g. convert JDBC Timestamps to joda-time DateTime and where I will generate constraints like @Pattern(..) from above?
  4. Implement DAO Layer
  5. Implement Repository Layer
  6. Implement Service Layer
  7. ...

Does this make sense or am I missing something here? I am asking because until now I was one of those "I don't want to write SQL because I don't want to know anything about the underlying mechanics" and let Hibernate create my entire database for me. But after reading about a lot of major drawbacks and problems that Hibernate brings with it I am (almost) convinced that it would be better to do it the way I described above.

I am considering using the open source version of JOOQ at first until - hopefully one day - money comes back in to allow me to go for a developer license of JOOQ.

Having said that I'm still open to alternatives and ready to not use Hibernate or JOOQ if the alternative can support my needs which are basically

  • Optimizable if needed
  • Typesafety
  • Confirmability (which Hibernate does barely offer afaics)
  • Does not lean against possible migration processes later on
  • Scalability

[1] https://vimeo.com/28885655
[2] https://itroman.wordpress.com/2010/12/05/why-i-do-hate-hibernate/
[3] http://www.sickenger.com/2013/02/hibernate-just-stop-it/

Community
  • 1
  • 1
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • SO jooq tad info list similar products (i.e. standard Hipernate "generalisation" aka JPA), but skips Batis family (first iBatis changed to myBatis) I had used iBatis +/- 2005-2010, can say is middle of the road – Jacek Cz Sep 20 '15 at 12:05
  • I think you might get better answers if you asked individual, concrete questions rather than one big one... – Lukas Eder Sep 21 '15 at 06:42
  • 1
    @LukasEder Well, yes, to be honest I knew that you will find this question sooner or later and I was hoping to kill a few birds with one stone :D But I can as well separate my question into 1) Allowed character patterns 2) Extend code generator 3) Caching 4) Workflow with JOOQ. – Stefan Falk Sep 21 '15 at 07:57
  • 1
    @LukasEder I have created [this question about allowed-character constraints](http://stackoverflow.com/questions/32690628/jooq-allowed-character-constraints) and [this question about caching](http://stackoverflow.com/questions/32690718/jooq-and-caching). :) – Stefan Falk Sep 21 '15 at 08:38
  • Thanks :) Will look into the concrete ones first (1-3). These can be answered objectively. The workflow is probably best answered by the community. – Lukas Eder Sep 21 '15 at 08:49
  • @LukasEder Thank you! :) – Stefan Falk Sep 21 '15 at 09:18

0 Answers0