Author Archives: Stanislav_Panteleev

Java.Hibernate.Medium.When to choose which strategy ?

✅ Short Answer SINGLE_TABLE → best for simple hierarchies with similar subclasses, prioritizing read performance. JOINED → best for normalized schemas when subclasses have many unique fields → prioritizes schema design and data integrity. TABLE_PER_CLASS → best when subclasses are … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.When to choose which strategy ?

Java.Hibernate.Medium.Explain the TABLE_PER_CLASS strategy.

✅ Short Answer The TABLE_PER_CLASS strategy maps each concrete subclass in an inheritance hierarchy to its own separate table, each with all fields from the base class + subclass.There’s no table for the abstract base class. 🔎 Detailed Explanation 🔹 … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Explain the TABLE_PER_CLASS strategy.

Java.Hibernate.Medium.Explain the JOINED strategy.

✅ Short Answer The JOINED strategy maps each class in an inheritance hierarchy to its own table, linking them by foreign keys, and represents a more normalized approach compared to SINGLE_TABLE. 🔎 Detailed Explanation 🔹 In JOINED, each entity class … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Explain the JOINED strategy.

Java.Hibernate.Medium.Explain the SINGLE_TABLE strategy.

understanding SINGLE_TABLE is key because it’s the most common (and default) inheritance strategy in JPA/Hibernate. Let’s break it down clearly: ✅ Short Answer The SINGLE_TABLE strategy stores all entities in an inheritance hierarchy in a single database table, using a … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Explain the SINGLE_TABLE strategy.

Java.Hibernate.Medium.What is default inheritance strategy ?

✅ Short Answer The default inheritance strategy in JPA/Hibernate is SINGLE_TABLE. 🔎 Detailed Explanation If you define an inheritance hierarchy with @Inheritance or even without specifying the strategy, JPA assumes: This means: All classes in the hierarchy share one table … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What is default inheritance strategy ?

Java.Hibernate.Medium.What inheritance strategies does Hibernate support?

✅ Short Answer Hibernate supports three main inheritance mapping strategies:1️⃣ SINGLE_TABLE → all classes in one table.2️⃣ JOINED → one table per class, joined by foreign keys.3️⃣ TABLE_PER_CLASS → one table per concrete class. 🔎 Detailed Explanation 🔹 1) SINGLE_TABLE … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What inheritance strategies does Hibernate support?

Java.Hibernate.Medium.Can we use subqueries in JPQL ?

✅ Short Answer Yes — JPQL supports subqueries, but only in the WHERE and HAVING clauses, not in the FROM clause. 🔎 Detailed Explanation 🔹 Where you can use subqueries in JPQL✅ WHERE clause → use a subquery to filter … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Can we use subqueries in JPQL ?

Java.Hibernate.Medium.What’s the difference between fetch joins and normal joins in HQL?

✅ Short Answer A normal join (JOIN, LEFT JOIN) combines tables/entities for filtering or constraints, but does not fetch related entities into your object graph. A fetch join (JOIN FETCH) loads the associated entities eagerly along with the parent in … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What’s the difference between fetch joins and normal joins in HQL?

Java.Hibernate.Medium.how JOIN FETCH solves the N+1 problem ?

✅ Short Answer A JOIN FETCH in JPQL/HQL tells Hibernate to eagerly load the parent and its associated entities in a single SQL query, instead of using separate queries per association.This eliminates the N+1 problem by reducing the number of … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.how JOIN FETCH solves the N+1 problem ?

Java.Hibernate.Medium.What is N+1 problem ?

✅ Short Answer The N+1 problem happens when an ORM (like Hibernate) executes 1 query to load N parent entities, and then N separate queries (1 per parent) to load their associated child entities → resulting in 1 + N … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What is N+1 problem ?