Category Archives: Без рубрики

Java.Hibernate.Medium.So we don’t need write here “on tableA.key = tableB.foreignKey” ?

✅ Short Answer Correct: In JPQL/HQL joins, you do not write ON tableA.key = tableB.foreignKey like in SQL.Instead, you navigate mapped entity relationships using Java object paths (e.g., o.customer) → JPA knows how to join based on the entity mappings … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.So we don’t need write here “on tableA.key = tableB.foreignKey” ?

Java.Hibernate.Medium.How do you join tables using HQL?

In JPA, you join tables by navigating entity relationships in JPQL/HQL queries, using JOIN, LEFT JOIN, or JOIN FETCH — just like in Hibernate HQL — since JPA uses JPQL as its standard query language. 🔎 Detailed Explanation JPA Joins … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.How do you join tables using HQL?

Java.Hibernate.Medium.How do you join tables using HQL?

✅ Short Answer In HQL (and JPQL), you join tables by navigating entity associations using JOIN, LEFT JOIN, and their FETCH variants — using entity relationships, not table names. 🔎 Detailed Explanation Types of joins you can use in HQL:1️⃣ … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.How do you join tables using HQL?

Java.Hibernate.Medium.What are positional vs. named parameters in HQL?

✅ Short Answer Positional parameters use index-based placeholders like ?1, ?2, etc., which are set by their numeric position in the query. Named parameters use named placeholders like :name, :status, which are set by their explicit names. 🔎 Detailed Explanation … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What are positional vs. named parameters in HQL?

Java.Hibernate.Medium.Describe all types of queries, including spring ones, when to use which ?

✅ Main Types of Queries 🔹 1) JPQL (Java Persistence Query Language) Queries What: Object-oriented, database-agnostic query language operating on entity classes and their fields. How: Dynamic JPQL → createQuery(“SELECT e FROM MyEntity e WHERE …”) Named JPQL queries → … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Describe all types of queries, including spring ones, when to use which ?

Java.Hibernate.Medium.Give examples of different types of queries ?

✅ Short Answer Alternatives to named queries include: Dynamic JPQL queries created at runtime with createQuery(). Criteria API, which builds type-safe queries programmatically. Native SQL queries for complex or DB-specific needs. Framework-specific solutions (e.g., Spring Data JPA repository methods with … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Give examples of different types of queries ?

Java.Hibernate.Medium.Why do i need named queries ?

✅ Short Answer You need named queries to centralize, reuse, and pre-validate your queries, improving maintainability, consistency, and safety across your application. 🔎 Detailed Explanation 🔹 Centralization Instead of scattering query strings across your codebase, you define them once, tied … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Why do i need named queries ?

Java.Hibernate.Medium.What are named queries and how do you define them?

✅ Short Answer Named queries are predefined, reusable JPQL or SQL queries associated with entity classes, given a unique name.You define them using the @NamedQuery or @NamedNativeQuery annotations — or XML mappings — and later execute them by name in … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What are named queries and how do you define them?

Java.Hibernate.Medium.What is the difference between detach() and delete()?

✅ Short Answer detach(): removes an entity from the current persistence context — it becomes detached, but stays in the database. delete() (or EntityManager.remove()): marks the entity for deletion from the database, and after commit, its row is permanently removed. … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.What is the difference between detach() and delete()?

Java.Hibernate.Medium.Explain cascading types like CascadeType.PERSIST and CascadeType.REMOVE.

✅ Short Answer CascadeType.PERSIST → when you save the parent entity, Hibernate automatically persists associated child entities. CascadeType.REMOVE → when you delete the parent entity, Hibernate automatically deletes associated child entities. 🔎 Detailed Explanation Cascading in JPA/Hibernate allows certain operations … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Medium.Explain cascading types like CascadeType.PERSIST and CascadeType.REMOVE.