Author Archives: Stanislav_Panteleev

Java.Hibernate.Beginner.What does the @GeneratedValue annotation do?

The @GeneratedValue annotation in JPA/Hibernate tells the persistence provider how to automatically generate values for the primary key field when a new entity is persisted.It works together with @Id to specify the strategy for generating unique identifiers. 🔹 What does … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What does the @GeneratedValue annotation do?

Java.Hibernate.Beginner.What types of @GeneratedValue we have ?

The @GeneratedValue annotation lets you tell JPA/Hibernate how to automatically generate primary key values. You choose the strategy using strategy = GenerationType.XXX, where the main options are: 🔹 1️⃣ GenerationType.IDENTITY Relies on the database’s auto-increment or identity columns. The database … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What types of @GeneratedValue we have ?

Java.Hibernate.Beginner.What is the @Id annotation used for?

The @Id annotation marks a field or getter in a JPA entity as the primary key, meaning it uniquely identifies each entity instance and maps to the primary key column in the database table. 🔹 Why is it important?✅ Every … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is the @Id annotation used for?

Java.Hibernate.Beginner.What does the @Table annotation do?

The @Table annotation in JPA/Hibernate is used in combination with @Entity to customize the mapping between your Java class and the database table.It allows you to explicitly specify the table name and define additional table-level constraints like unique keys or … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What does the @Table annotation do?

Java.Hibernate.Beginner.What is the purpose of the @Entity annotation?

The @Entity annotation marks a Java class as a persistent entity in JPA/Hibernate, meaning it should be mapped to a table in the database.It tells the JPA provider (Hibernate) to manage instances of the class as rows in a relational … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is the purpose of the @Entity annotation?

Java.Hibernate.Beginner.What are transient, persistent, and detached objects in Hibernate?

🔹 1️⃣ Transient objects✅ Newly created objects that are not associated with any Hibernate session and have no representation in the database yet.✅ Hibernate does not track them → changes are ignored unless you explicitly save them.✅ Created with new … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What are transient, persistent, and detached objects in Hibernate?

Java.Hibernate.Beginner.What is optimistic locking in Hibernate?

Optimistic locking is a concurrency control strategy in Hibernate where multiple transactions can read and update the same data concurrently, but Hibernate checks for conflicts at commit time by comparing a version field.If another transaction modified the data in the … Continue reading →

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

Java.Hibernate.Beginner.What is pessimistic locking in Hibernate?

Pessimistic locking is a concurrency control strategy in Hibernate (and relational databases in general) where a row-level lock is acquired in the database as soon as you read or access a record, preventing other transactions from modifying it until your … Continue reading →

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

Java.Hibernate.Beginner.What is cascade in Hibernate?

Cascade in Hibernate specifies which operations performed on a parent entity should automatically propagate to its related child entities. It controls whether actions like save, update, delete, or refresh applied to one entity also affect its associated entities. 🔹 Why … Continue reading →

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

Java.Hibernate.Beginner. What is eager fetching?

Eager fetching means loading an association immediately along with the parent entity, so related entities are retrieved in the same query (if possible) or with additional immediate queries.This is the opposite of lazy loading: instead of deferring, eager fetching ensures … Continue reading →

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