HIBERNATE / CATATAN</>↗Hibernate12 Jun 2025
To handle database connections in a Hibernate standalone application, you need to set up Hibernate configuration carefully and ensure the correct management of the Hibernate SessionFactory and Session objects. Below are the general steps to achieve this: Steps to Handle Database Connections in Hibernate Standalone Application 1. Add Required Hibernate Dependencies Ensure you include the […]
HIBERNATE / CATATAN</>↗Hibernate12 Jun 2025
Defining a primary key using the @Id and @GeneratedValue annotations in Hibernate (or JPA) is straightforward and commonly used to automate primary key generation for database entities. Here’s a guide: Steps: Use @Id annotation: Marks a field in your entity class as the primary key. Use @GeneratedValue annotation: Specifies that the primary key values should […]
HIBERNATE / CATATAN</>↗Hibernate11 Jun 2025
To write a simple JPQL (Java Persistence Query Language) query using Hibernate, follow these steps: Example: Basic JPQL Query For example, consider we have an entity: Employee package org.kodejava.hibernate; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.Table; @Entity @Table(name = "employee") public class Employee { @Id private Long id; private String name; private String department; private Double […]
HIBERNATE / CATATAN</>↗Hibernate11 Jun 2025
Configuring Hibernate with an H2 in-memory database is quite straightforward. Below is a guide for configuring Hibernate with an H2 database in a Spring Boot or standalone Jakarta EE project. Configuration for Hibernate with H2 in-memory database 1. Add Dependencies Ensure you have the necessary dependencies in your project. For a Maven project, include the […]
HIBERNATE / CATATAN</>↗Hibernate10 Jun 2025
Hibernate ORM 6 introduces several changes to its API compared to previous versions, especially in how SessionFactory and Session are used due to compliance with Jakarta EE and its updated imports (jakarta.persistence.*). Here’s a simple guide to using SessionFactory and Session in Hibernate 6: 1. Add Hibernate Dependencies Make sure to include the Hibernate 6 […]
HIBERNATE / CATATAN</>↗Hibernate10 Jun 2025
To map a Java class to a database table using JPA annotations, you primarily use annotations provided by jakarta.persistence. Here is a step-by-step guide: Key annotations for mapping: @Entity Marks the class as an entity that is mapped to a table. @Table (optional) Specifies the table name in the database. If omitted, the default table […]