Hibernate dynamic-insert and dynamic-update

In this tutorial, we’ll explore the @org.hibernate.annotations.Entity annotation and specifically focus on its dynamicInsert and dynamicUpdate properties. These properties can be highly useful in optimizing database interactions by preventing unnecessary SQL updates and inserts. 1. Introduction to @Entity with dynamicInsert and dynamicUpdate Hibernate provides some additional features to the standard JPA annotations. One of these … Read more

How to lazy load your Entity relations ?

This tutorial will teach you how to configure and optimize the fetch type strategy used in your Jakarta EE / Hibernate applications. In JPA terms, the FetchType strategy defines strategies for fetching data from the database. The default FetchType depends on the cardinality of the relationship. Here is a quick summary of defaults: Fetch Strategy … Read more

Many to Many Hibernate/JPA Example

In Java Persistence API (JPA), the Many-to-Many relationship represents a common scenario where multiple instances of one entity are associated with multiple instances of another entity. This tutorial will guide you through the process of implementing a Many-to-Many relationship using JPA.

Read more

One to Many Hibernate/JPA example

In this article we will learn how to implement a One to Many Entity Relation between two objects in an Hibernate/JPA application. One to Many overview In RDBMS terms, a one-to-many relationship exists when one record in table A may be linked with many records in table B. On the other hand, one record in … Read more

How to create an Index on your Entity Beans?

An index is a data structure such as B-Tree that improves the speed of data retrieval on a table at the cost of additional writes and storage to maintain it. When using plain SQL, to add an index for a column or a set of columns, you use the CREATE INDEX statement as follows: CREATE INDEX … Read more

One to One Hibernate/JPA Example

In this tutorial we will demonstrate how to set up Hibernate One-to-One Mapping between two Database tables. We will show how to create and deploy four applications using different approaches to set up the Object relationship.

Read more

How to map a BLOB field with JPA?

@javax.persistence.Lob can be used to specify that the annotated field should be represented as BLOB (binary data) in the DataBase. A Lob may be either a binary or character type. Common use of @Lob is to annotate a HashMap field inside your Entity to store some of the object properties which are not mapped into … Read more

How to disable updates for a field of an Entity EJB?

If you need to select which columns need update when executing a CMP statement you can use the “updatable” attribute on the @Column annotation. Setting “updatable” = false will assume that the column is not always included in the SQL update statement. Here is an example: import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import … Read more

Hibernate Data Filters

Filtering data is one of the most common Task of an application. This is usually achieved by adding WHERE clauses to your queries. In case the filters are defined dynamically by the user it becomes a more complex issue. A very powerful option for creating dynamic conditions to your applications are Criteria API, however it’s … Read more