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:
- Write my database in MySQL by hand
- Use FlywayDB for migration-versioning and deploy the database to Tomcat
- 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?
- Is this where my code generator extension will e.g. convert JDBC Timestamps to joda-time
- Implement DAO Layer
- Implement Repository Layer
- Implement Service Layer
- ...
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/