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

Java.Hibernate.Beginner.What is query cache in Hibernate?

The query cache in Hibernate is an optional, second-level caching mechanism that stores the results of HQL or Criteria queries, so that the same query with the same parameters can return results without re-executing the SQL against the database. 🔹 … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is query cache in Hibernate?

Java.Hibernate.Beginner.Does sessionFactory lives in sessionManager ?

Not quite — there isn’t actually a Hibernate class called SessionManager. But let’s unpack the correct relationship between these components: 🔹 SessionFactory: The SessionFactory is the central, heavyweight Hibernate component. It’s created once per application (singleton) and is thread-safe. It … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Does sessionFactory lives in sessionManager ?

Java.Hibernate.Beginner.Do i need openSession in SpringBoot ?

No, you almost never need to manually call openSession() in a typical Spring Boot application. Spring Boot, through Spring Data JPA or Spring’s @Transactional support, manages the Hibernate session lifecycle automatically for you. 🔹 How it works in Spring Boot: … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Do i need openSession in SpringBoot ?

Java.Hibernate.Beginner.Session lifecycle

✅ Hibernate Session Lifecycle 🔹 1) Open You open a new Session from a SessionFactory: A new first-level cache is created, and the session is ready to interact with the database. 🔹 2) Begin Transaction (optional but recommended) Start a … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Session lifecycle

Java.Hibernate.Beginner.What is second-level cache in Hibernate?

The second-level cache (2nd-level cache) is an optional, shared Hibernate cache that stores entities (and sometimes collections) beyond the scope of a single session — allowing data to be reused across multiple sessions in the same application, which can dramatically … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is second-level cache in Hibernate?

Java.Hibernate.Beginner.What is first-level cache in Hibernate?

The first-level cache is Hibernate’s mandatory, built-in caching mechanism that automatically stores persistent entities within the scope of a single Hibernate Session. 🔹 Key characteristics:✅ Enabled by default — you cannot disable it.✅ Scoped to a single Session — each … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is first-level cache in Hibernate?

Java.Hibernate.Beginner.How do you map a Java class to a database table in Hibernate?

You can map a Java class to a database table in Hibernate in two main ways: 🔹 1) Using JPA annotations (modern, recommended)Add annotations directly to your Java class: ✅ With annotations: @Entity: tells Hibernate this class should be persisted. … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.How do you map a Java class to a database table in Hibernate?

Java.Hibernate.Beginner.When i say save, is it saved to cache ?

✅ When you call save() on an entity, does it save to the cache or the database? Answer:When you call session.save(entity) in Hibernate: 🔹 1) First, it saves the entity to the session’s first-level cache: The entity becomes persistent: Hibernate … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.When i say save, is it saved to cache ?

Java.Hibernate.Beginner.Explain Enity lifecycle

Hibernate defines three states an entity can be in during its lifetime: 🔹 1) Transient What it means: The object exists in Java memory but is not yet known to Hibernate, and not saved to the database. Example: If you … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Explain Enity lifecycle

Java.Hibernate.What is an entity in Hibernate?

✅ What is an entity in Hibernate? Answer:In Hibernate (and JPA), an entity is a lightweight, persistent Java object whose state is mapped to a table row in a relational database. Entities represent the domain model of your application and … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.What is an entity in Hibernate?