Ultimate Guide to Implementing equals() and hashCode() with Hibernate
|

Ultimate Guide to Implementing equals() and hashCode() with Hibernate

The implementation of the equals() and hashCode() methods for entity classes is an often discussed question. Do you really need them? There are lots of applications that work perfectly fine using Java’s default methods provided by the Object class. And if you need to implement them, how should you do that? Should you use all attributes…

5 Things Beginners Need to Know Before Using JPA / Hibernate / EclipseLink
|

5 Things Beginners Need to Know Before Using JPA / Hibernate / EclipseLink

A solid understanding of JPA and its implementations is still one of the most in-demand skills among Java developers. So, it’s no surprise that there are several blog posts, books, and courses available that teach you how to implement a persistence layer using the JPA specification. I even recorded a JPA for Beginners course myself. But…

What’s the difference between persist, save, merge and update? Which one should you use?
|

What’s the difference between persist, save, merge and update? Which one should you use?

JPA and Hibernate provide different methods to persist new and to update existing entities. You can choose between JPA’s persist and merge and Hibernate’s save and update methods. It seems like there are 2 pairs of 2 methods that do the same.  You can use the methods persist and save to store a new entity…

Best Practices for Many-To-One and One-To-Many Association Mappings
|

Best Practices for Many-To-One and One-To-Many Association Mappings

When you model your database, you will most likely define several many-to-one or one-to-many associations. And it’s, of course, the same when you model your entities. It’s quite easy to do that with JPA and Hibernate. You just need an attribute that represents the association and annotate it with a @ManyToOne or @OneToMany association. But…

5 Things You Need to Know When Using Hibernate with Mysql
|

5 Things You Need to Know When Using Hibernate with Mysql

One of the benefits of using JPA and Hibernate is that it provides an abstraction of database-specific dialects and features. So, in theory, you can implement an application, connect it to one of the supported databases and it will run without any code changes. Hibernate does that really well. But let’s be honest, you didn’t…