How to use Hibernate Annotations to work with Database

Hibernate annotations is a solution to map Java classes and database’s tables without using XML file. So in the tutorial, JavaSampleApproach will guide you through the steps of configuring Hibernate Annotations to work with Database.

Related articles:
How to start development with Hibernate – XML Mapping File Hibernate

Continue reading “How to use Hibernate Annotations to work with Database”

Hibernate Query Language – HQL + Java 8 + MySQL

Hibernate provides a powerful language for queries: Hibernate Query Language (HQL). HQL is simmilar to SQL but it works with Java objects instead of tables. The tutorial shows you the advantages of HQL and how to work with it.

Continue reading “Hibernate Query Language – HQL + Java 8 + MySQL”

How to create Composite Primary Key – Spring JPA + Spring Boot + MySQL

In the tutorial, JavaSampleApproach will introduce step-by-step to create Composite Primary Key with @Embeddable annotation.

Related articles:
How to configure Spring JPA One to Many Relationship – SpringBoot

Continue reading “How to create Composite Primary Key – Spring JPA + Spring Boot + MySQL”

How to use Hibernate Lazy Fetch and Eager Fetch Type – Spring Boot + MySQL

Many case asking that “Spring JPA lazy loading not working!”. So it is very hard to start with Hibernate and Spring JPA. In the tutorial, I will help you understand SpringJPA Hibernate Lazy Fetch Type and Eager Fetch Type by example code with Spring Boot & MySql database using with Spring JPA annotations’ @onetoone and @onetomany

– Lazy Loading is a design pattern which is used to defer initialization of an object as long as it’s possible. The FetchType.LAZY tells Hibernate to only fetch the related entities from the database when you use the relationship
(This does not load the relationships unless you invoke it via the getter method)
– Eager Loading is a design pattern in which data initialization occurs on the spot. Eager initialization takes more memory consumption and processing speed is slow. FetchType.EAGER = This loads all the relationships.

Related articles:
How to configure Spring JPA One to Many Relationship – SpringBoot
How to start development with Hibernate – XML Mapping File Hibernate

Continue reading “How to use Hibernate Lazy Fetch and Eager Fetch Type – Spring Boot + MySQL”

How to resolve Hibernate OutOfMemoryError problem – Hibernate Batch processing

When using Hibernate for saving a large number of entities to database, You can meet an OutOfMemoryException. The tutorial will show the case and resolve it with Hibernate Batch processing.

Related articles:
How to start development with Hibernate – XML Mapping File Hibernate

Continue reading “How to resolve Hibernate OutOfMemoryError problem – Hibernate Batch processing”