Home » Tag Archives: JBoss Hibernate (page 7)

Tag Archives: JBoss Hibernate

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 »

Hibernate Facts: Favoring bidirectional Set(s) vs List(s)

jboss-hibernate-logo

Hibernate is a great ORM tool, and it eases development considerably, but it has a lot of gotchas you must be aware of if you want to use it properly. On medium to large projects it’s very common to have bidirectional parent-child associations, which allow us to navigate both ends of a given relationship. When it comes to controlling the ...

Read More »

Natural Ids in Hibernate

jboss-hibernate-logo

A natural id is a property or a set of properties that would identify an entity uniquely. We can have at-most one natural id defined for an entity. When Hibernate sees natural-id tag in an entity mapping file, it automatically creates unique and not-null constraints on the properties constituting natural-id. First, let us look at examples of simple and composite ...

Read More »

How to maintain history of tables in Hibernate

jboss-hibernate-logo

To Maintain history of database or keep track of modification of database table row , we create a version table that contains fields identical to original table.Whenever original table gets changed , we create another entry in version table. So for every update query , we have to write an insert query in version table . There is a module ...

Read More »

Spring JPA Data + Hibernate + MySQL + Maven

spring-data-logo

Development of web-applications with the help of Spring MVC implies creation of several logical layers of architecture. One of the layers is a DAO (Repository) layer. It is responsible for communication with a database. If you developed the DAO layer at least once, you should know that it involves a lot of boilerplate code. A Spring Data take a part ...

Read More »
Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.