@OneToMany relationship with JPA and Hibernate
Introduction In a relational database system, a one-to-many association links two tables based on a Foreign Key column so that the child table record references the Primary Key of the parent table row. Mapping We have two choices for that: a unidirectional @OneToMany association bidirectional @OneToMany association The bidirectional association requires the child entity mapping to provide a @ManyToOne annotation, which is responsible for controlling the association. On the other hand, the unidirectional @OneToMany association is just the parent-side that defines the relationship.
Spring: DI Container
The Spring Framework is a popular and widely-used open-source framework for building Java-based applications. It provides a comprehensive programming and configuration model for modern Java-based enterprise applications, including support for dependency injection, aspect-oriented programming, transaction management, and much more. Spring is designed to simplify the development process and improve the maintainability and scalability of applications. In this article, we will explore the key features of the Spring Framework and how it can be used to build robust, scalable applications.
Why Hibernate over JDBC
Why Hibernate is the preferred choice? In today’s technology-driven world, databases are the backbone of almost every software application. Database connectivity is a crucial component of any application development. The most commonly used database connectivity technologies are JDBC and Hibernate. While JDBC has been the traditional method of connecting to a database, Hibernate has emerged as a popular alternative. So, what makes Hibernate the preferred choice over JDBC? Let’s explore.
@ComponentScan: Spring boot
Fun fact: Those who are pondering that where our spring boot application is scanning for the components. We use the @SpringBootApplication annotation, but it’s a combination of three annotations: @Configuration @EnableAutoConfiguration @ComponentScan
About
about
Socials
socials