Home » Tag Archives: JBoss Hibernate (page 6)

Tag Archives: JBoss Hibernate

Workshop on Creating a Personal MusicManager Web Application with Struts2, Hibernate and MySQL

jboss-hibernate-logo

Overview: In this workshop tutorial we’ll develop a personal music manager application using Struts 2, Hibernate and MySQL database. The web application can be used to add your music collection to the database. We’ll display form to add the record and underneath we’ll show all the music collections. From each row the record can be deleted by clicking ‘Delete’ link. ...

Read More »

Hibernate Facts: Always check Criteria API SQL queries

java-interview-questions-answers

Criteria API is very useful for dynamically building queries, but that’s the only use case where I’d use it. Whenever you have an UI with N filters that may arrive in any M combinations, it makes sense to have an API to construct queries dynamically, since concatenating strings is always a path I’m running away from. The question is, are ...

Read More »

Hibernate Facts: Integration testing strategies

jboss-hibernate-logo

I like Integration Testing, it’s a good way to check what SQL queries Hibernate generates behind-scenes. But Integration Tests require a running database server, and this is the first choice you have to make. 1. Using a production-like local database server for Integration Testing For a production environment I always prefer using incremental DDL scripts, since I can always know ...

Read More »

ID Lists Aren’t the Best Solution for the N+1 Problem

jboss-hibernate-logo

In their eternal attempts to circumvent the N+1 problem, Hibernate users often resort to IN predicates with ID lists. In this post, we’ll see how those users might just be replacing a horrible thing with a bad one, which is better but not yet good. Here’s why: The N+1 Problem The N+1 problem is a well understood issue, documented in ...

Read More »

Hibernate Facts: Equals and HashCode

jboss-hibernate-logo

Every Java object inherits the equals and hashCode methods, yet they are useful only for Value objects, being of no use for stateless behavior oriented objects. While comparing references using the “==” operator is straight forward, for object equality things are a little bit more complicated. Since you are responsible for telling what equality means for a particular object type, ...

Read More »

Hibernate Facts: Multi level fetching

jboss-hibernate-logo

It’s quite common to retrieve a root entity along with its children associations on multiple levels. In our example we need to load a Forest with its Trees and Branches and Leaves, and we will try to see have Hibernate behaves for three collection types: Sets, Indexed Lists, and Bags. This is how our class hierarchy looks like:     ...

Read More »

Hibernate Facts: Knowing flush operations order matters

jboss-hibernate-logo

Hibernate shifts the developer mindset from thinking SQL into thinking object state transitions. According to Hibernate Docs entity may be in one of the following states:                   new/transient: the entity is not associated to a persistence context, be it a newly created object the database doesn’t know anything about. persistent: the entity ...

Read More »

Hibernate Facts: The importance of fetch strategy

jboss-hibernate-logo

When it comes to working with an ORM tool, everybody acknowledges the importance of database design and Entity-to-Table mapping. These aspects get a lot of attention, while things like fetching strategy might be simply put-off. In my opinion, the entity fetching strategy shouldn’t ever be separated from the entity mapping design, since it might affect the overall application performance, unless ...

Read More »

Efficiently delete data with JPA and Hibernate

jboss-hibernate-logo

You may come to the situation where you have to perform a bulk deletion on a huge amount of datasets stored in a relational database. If you use JPA with Hibernate as underlying OR mapper, you might try to call the remove() method of the EntityManager in a way like the following:               public ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close