Preguntas y respuestas de entrevista mas solicitadas y pruebas en linea
Plataforma educativa para preparacion de entrevistas, pruebas en linea, tutoriales y practica en vivo

Desarrolla tus habilidades con rutas de aprendizaje enfocadas, examenes de practica y contenido listo para entrevistas.

WithoutBook reune preguntas de entrevista por tema, pruebas practicas en linea, tutoriales y guias comparativas en un espacio de aprendizaje responsivo.

Preparar entrevista

Hibernate preguntas y respuestas de entrevista

Test your skills through the online practice test: Hibernate Quiz Online Practice Test

Diferencias relacionadas

Pregunta 26. What is the difference between and merge and update?

Use update() if you are sure that the session does not contain an already persistent instance with the same identifier, and merge() if you want to merge your modifications at any time without consideration of the state of the session.

Es util? Agregar comentario Ver comentarios
 

Pregunta 27. How do you define sequence generated primary key in hibernate?

Using <generator> tag.
Example:-
<id column="USER_ID" name="id" type="java.lang.Long">
<generator class="sequence">
<param name="table">SEQUENCE_NAME</param>
<generator>
</id>

Es util? Agregar comentario Ver comentarios
 

Pregunta 28. Define cascade and inverse option in one-many mapping?

cascade enable operations to cascade to child entities.
cascade="all|none|save-update|delete|all-delete-orphan"
inverse mark this collection as the "inverse" end of a bidirectional association. inverse="true|false" Essentially "inverse" indicates which end of a relationship should be ignored, so when persisting a parent who has a collection of children, should you ask the parent for its list of children, or ask the children who the parents are?

Es util? Agregar comentario Ver comentarios
 

Pregunta 29. What does it mean to be inverse?

It informs hibernate to ignore that end of the relationship. If the one-to-many was marked as inverse, hibernate would create a child->parent relationship (child.getParent). If the one-to-many was marked as non-inverse then a child->parent relationship would be created.


In Hibernate, only the ā€œrelationship ownerā€ should maintain the relationship, and the ā€œinverseā€ keyword is created to defines which side is the owner to maintain the relationship. However the ā€œinverseā€ keyword itself is not verbose enough, I would suggest change the keyword to ā€œrelationship_ownerā€œ.

In short, inverse=ā€trueā€ means this is the relationship owner, and inverse=ā€falseā€ (default) means it’s not.

Suppose Stock is parent and StockDailyRecords is Child object.

Inverse keyword is applied in one to many relationship. Here’s the question, if save or update operation perform in ā€œStockā€ object, should it update the ā€œstockDailyRecordsā€ relationship?

1. inverse=ā€trueā€
If inverse=ā€trueā€ in the set variable, it means ā€œstock_daily_recordā€ is the relationship owner, so Stock will NOT UPDATE the relationship.

2. inverse=ā€falseā€
If inverse=ā€falseā€ (default) in the set variable, it means ā€œstockā€ is the relationship owner, and Stock will UPDATE the relationship.

If keyword ā€œinverseā€ is not define, the inverse = ā€œfalseā€ will be used, which is

Es util? Agregar comentario Ver comentarios
 

Pregunta 30. What do you mean by Named - SQL query?

Named SQL queries are defined in the mapping xml document and called wherever required.
Example:
<sql-query name = "empdetails">
<return alias="emp" class="com.test.Employee"/>
SELECT emp.EMP_ID AS {emp.empid}, emp.EMP_ADDRESS AS {emp.address}, emp.EMP_NAME AS {emp.name} FROM Employee EMP WHERE emp.NAME LIKE :name
</sql-query>

Invoke Named Query :
List people = session.getNamedQuery("empdetails") .setString("TomBrady", name) .setMaxResults(50) .list();

Es util? Agregar comentario Ver comentarios
 

Lo mas util segun los usuarios:

Copyright Ā© 2026, WithoutBook.
JDBC vs HibernateJPA vs HibernateHibernate 3 vs Hibernate 4