HIBERNATE / CATATAN</>↗Hibernate17 Jun 2025
In Hibernate, you can customize table and column names using JPA annotations such as @Table and @Column. These annotations allow you to define how your entity classes map to the database tables and columns. Here’s how you can do it: Customize the Table Name To specify a custom table name, use the @Table annotation on […]
HIBERNATE / CATATAN</>↗Hibernate16 Jun 2025
In Hibernate (or when using JPA with Hibernate), you can use annotations such as @CreationTimestamp and @UpdateTimestamp to handle automatic auditing for fields such as creation time and last updated time. These annotations are commonly used to automatically populate Date or LocalDateTime fields whenever an entity is created or updated. Here’s how you would implement […]
HIBERNATE / CATATAN</>↗Hibernate15 Jun 2025
In Hibernate (or JPA in general), the @Embeddable and @Embedded annotations are used to help manage object-relational mapping for complex types (value types) within entities. These annotations allow you to define reusable and nested objects that don’t require their own database table but are saved as part of the owning entity. Here’s how to use […]
HIBERNATE / CATATAN</>↗Hibernate14 Jun 2025
In Hibernate (and JPA), fetching strategies (lazy and eager) control how related entities are loaded from the database. Understanding how to use these strategies effectively is essential for optimizing application performance. Here’s what you need to know: 1. Eager Fetching Definition: When a relationship is marked as eager, Hibernate retrieves the related entity or collection […]
HIBERNATE / CATATAN</>↗Hibernate13 Jun 2025
To integrate Hibernate’s second-level cache with EHCache, follow these steps: Step 1: Add Dependencies Ensure that you have the required dependencies in your project: For Maven: <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>6.4.4.Final</version> </dependency> <dependency> <groupId>org.ehcache</groupId> <artifactId>ehcache</artifactId> <version>3.10.8</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifac...
HIBERNATE / CATATAN</>↗Hibernate13 Jun 2025
In Hibernate, you can use the @OneToMany and @ManyToOne annotations to map a one-to-many relationship. Below is a step-by-step explanation with an example: Explanation: One-To-Many Side: Use the @OneToMany annotation on the field representing the collection in the parent entity. Typically, this will be a List, Set, or other collection type. Many-To-One Side: Use the […]