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

Java.Hibernate.Beginner.Explain what means bidirectional ? What’s difference to unidirectional ?

🔹 Bidirectional relationshipA bidirectional relationship means both entities know about each other in your Java model: You can navigate the relationship from either side in your code. Both entities have fields referencing each other. Example: User has a UserProfile field, … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Explain what means bidirectional ? What’s difference to unidirectional ?

Java.Hibernate.Beginner.OneToOne.Bidirectional

A User entity has exactly one UserProfile, and each UserProfile belongs to exactly one User. 🔹 Entity 1: User 🔹 Entity 2: UserProfile 🔹 What happens here:✅ The UserProfile table has a foreign key column user_id referencing users.id.✅ UserProfile owns … Continue reading →

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

Java.Hibernate.Beginner.What is one-to-one mapping in Hibernate?

A one-to-one mapping in Hibernate represents a relationship where one entity instance is associated with exactly one instance of another entity, and vice versa. It models a real-world scenario where two tables have a one-to-one relationship (e.g., User ↔ UserProfile). … Continue reading →

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

Java.Hibernate.Beginner.How can you use native SQL queries in Hibernate?

You can execute raw SQL queries directly against the database using Hibernate’s native query API, which lets you write standard SQL (not HQL/JPQL) — useful when you need database-specific features or want maximum control. 🔹 How to create a native … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.How can you use native SQL queries in Hibernate?

Java.Hibernate.Beginner.How can i understad that i use HQL or JPQL ?

🔹 1️⃣ Context of your project JPQL is used if you’re working with JPA (javax.persistence / jakarta.persistence), e.g.: Your project uses JPA annotations (@Entity, @Id, etc.). You create queries using EntityManager.createQuery(). You rely on JPA-standard features like @PersistenceContext, @Transactional. HQL … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.How can i understad that i use HQL or JPQL ?

Java.Hibernate.Beginner.What is the difference between HQL and JPQL?

🔹 HQL (Hibernate Query Language)✅ Hibernate’s own object-oriented query language.✅ Introduced before the JPA standard existed.✅ Very similar to JPQL in syntax, but includes Hibernate-specific features, like: Support for querying Hibernate-specific features (e.g., some collection mappings). Functions that might not … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is the difference between HQL and JPQL?

Java.Hibernate.Beginner.What is the difference between HQL and SQL?

🔹 HQL (Hibernate Query Language)✅ Object-oriented query language → queries are written against Java entities and their properties, not database tables or columns.✅ Portable → Hibernate translates HQL into database-specific SQL, so you can switch databases without changing your queries.✅ … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.What is the difference between HQL and SQL?

Java.Hibernate.Beginner.Explain how can i change criteria api in run time, what does it mean ?

Answer:Changing Criteria API at runtime means you can build queries dynamically based on conditions only known during execution (e.g., user input, UI filters, request parameters) instead of writing fixed, hardcoded queries. 🔹 Why is this important? In real apps, search … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Explain how can i change criteria api in run time, what does it mean ?

Java.Hibernate.Beginner.What is the Criteria API in Hibernate?

The Criteria API in Hibernate is an object-oriented, programmatic way to build dynamic queries — instead of writing HQL or SQL strings manually, you construct queries using Java objects and method calls. 🔹 Why use Criteria API?✅ Useful when you … Continue reading →

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

Java.Hibernate.Beginner.Explain Polymorphic queries and give examples

Polymorphic queries in Hibernate mean you can query a superclass entity and automatically retrieve instances of all its subclasses — without explicitly mentioning each subclass.This happens because Hibernate maps your Java inheritance hierarchy, and HQL supports it natively. 🔹 When … Continue reading →

Posted in Без рубрики | Comments Off on Java.Hibernate.Beginner.Explain Polymorphic queries and give examples