The problem of AUTO JPA GenerationType with MySQL and Hibernate
Introduction In this post, I’ll show you why you should not rely on the AUTO GenerationType strategy if you’re using MySQL and Hibernate. As I already mentioned, you should never use the TABLE identifier generator since it does not scale properly.
The JPA EntityManager createNativeQuery is a Magic Wand
Introduction I found this very interesting question on the Hibernate forum, and, in this post, I want to demonstrate to you why native SQL queries are awesome.
How to replace the TABLE identifier generator with either SEQUENCE or IDENTITY in a portable way
Introduction As previously explained, the TABLE identifier generator does not scale, so you should avoid id. However, some enterprise applications might need to run on both MySQL (which does not support database sequences), as well as Oracle, PostgreSQL, and SQL Server 2012. This is article is going to explain how easily you can achieve this goal using the JPA mapping overriding.
Book Review – SQL Antipatterns
Introduction I’ve just finished the wonderful SQL Antipatterns book by Bill Karwin. The book is a must-have reference for any developer that has to interact with a relational database system. This post is a review of what this book is all about and why you should be interested in reading it.
Why you should never use the TABLE identifier generator with JPA and Hibernate
Introduction From a data access perspective, JPA supports two major types of identifiers: assigned generated The assigned identifiers must be manually set on every given entity prior to being persisted. For this reason, assigned identifiers are suitable for natural keys. For synthetic Primary Keys, we need to use a generated entity identifier, which is supported by JPA through the use of the @GeneratedValue annotation. There are four types of generated identifier strategies which are defined by the GenerationType enumeration: AUTO IDENTITY SEQUENCE TABLE The AUTO identifier generator strategy chooses one of the… Read More

