MCQs > IT & Programming > Hibernate MCQs > Basic Hibernate MCQs

Basic Hibernate MCQ

1. Which of the following is NOT a valid hibernate performance tuning strategy?

Answer

Correct Answer: Avoid clearing the whole Session after flushing

Note: This Question is unanswered, help us to find answer for this one

2. Which of the following is NOT a valid layer in hibernate framework?

Answer

Correct Answer: transaction layer

Note: This Question is unanswered, help us to find answer for this one

3. Which of the following is not a VALID hibernate interceptor event?

Answer

Correct Answer: SelectEvent

Note: This Question is unanswered, help us to find answer for this one

4. Which of the following is NOT a valid CascadeType value?

Answer

Correct Answer: DELETE

Note: This Question is unanswered, help us to find answer for this one

5. Which of the following is NOT true about Hibernate Template?

Answer

Correct Answer: Since it decouples the application from the spring framework, it is recommended that HibernateTemplate is always used for integration

Note: This Question is unanswered, help us to find answer for this one

6. Which of the following is not a Session method?

Answer

Correct Answer: Session.remove()

Note: This Question is unanswered, help us to find answer for this one

7. Which one of the following statements is true about the following HQL query: select p.number from employee e join e.phones p

Answer

Correct Answer: Because the "phones" is a collection association field, the path navigation couldn't continue

Note: This Question is unanswered, help us to find answer for this one

8. Which of the following is NOT true about sharding in Hibernate (Hibernate Shards)?

Answer

Correct Answer: Hibernate Shards can be conceptually divided into Generalized sharding logic, Application specific sharding logic and Hibernate Default sharding

Note: This Question is unanswered, help us to find answer for this one

9. Which of the following is NOT true about SessionFactory?

Answer

Correct Answer: It helps in customized extraction of data.

Note: This Question is unanswered, help us to find answer for this one

10. Which one of the following statement is NOT true about single table inheritance strategy?

Answer

Correct Answer: There shouldn't be any columns left unfilled in the single table strategy

Note: This Question is unanswered, help us to find answer for this one

11. Which of the following statements is True about one to one relationship mapping?

Answer

Correct Answer: The @JoinColumn annotation goes on the mapping of the entity that is mapped to the table containing the foreign key

Note: This Question is unanswered, help us to find answer for this one

12. Which one of the following statements is true about joining associations in Hibernate?

Answer

Correct Answer: In HQL the LEFT keyword in LEFT JOIN FETCH is optional

Note: This Question is unanswered, help us to find answer for this one

13. Which of the following statements is NOT true about persistent instance?

Answer

Correct Answer: An object is not persistent if it's retrieved from the database by the execution of query.

Note: This Question is unanswered, help us to find answer for this one

14. If you want to save your modifications at any time without knowing about the state of an session, then which of the following operations will you use:

Answer

Correct Answer: Merge

Note: This Question is unanswered, help us to find answer for this one

15. Which of the following correctly describes org.hibernate.cache log category?

Answer

Correct Answer: Log all second-level cache activity

Note: This Question is unanswered, help us to find answer for this one

16. Which one of the following statements is true about the following HQL query: select department from Department department join department.employees employee where employee.address.state = 'CA' and department.name='marketing'

Answer

Correct Answer: The department objects returned are lazy loaded.

Note: This Question is unanswered, help us to find answer for this one

17. Which of the following is NOT a valid org.hibernate.ConnectionReleaseMode?

Answer

Correct Answer: ON_OPEN

Note: This Question is unanswered, help us to find answer for this one

18. Which of the following is not TRUE about StatelessSession interface/implementation in Hibernate Batch?

Answer

Correct Answer: Operations performed using a stateless session cascade to associated instances

Note: This Question is unanswered, help us to find answer for this one

19. Which one of the following statements is NOT true about transient state?

Answer

Correct Answer: Transient instance is always associated with a row in a database

Note: This Question is unanswered, help us to find answer for this one

20. Which one of the following statement is NOT true about many to one relationship mapping?

Answer

Correct Answer: The @JoinColumn must be defined with @OneToMany annotation

Note: This Question is unanswered, help us to find answer for this one

21. Which one of the following statements is True about the following query: from Item as I where i.description = :description

Answer

Correct Answer: the Item indicates the name of the entity class and it's case sensitive

Note: This Question is unanswered, help us to find answer for this one

22. Which one of the following statements is NOT true about the following HQL query: from Item item join item.bids bid where item.description like '%gc%' and bid.amount > 100

Answer

Correct Answer: The bids collection of each Item will be eagerly loaded.

Note: This Question is unanswered, help us to find answer for this one

23. Which one of the following statements is NOT true about entity lifecycle events

Answer

Correct Answer: When the SQL for deletion of an entity gets sent to the database, the PostRemove event will get fired and it indicates success of deletion

Note: This Question is unanswered, help us to find answer for this one

24. Which one of the following statements is NOT true about join strategy (table per subclass)?

Answer

Correct Answer: Join strategy is the most efficient way to insert data

Note: This Question is unanswered, help us to find answer for this one

25. Which of the following correctly describes org.hibernate.SQL log category?

Answer

Correct Answer: Log all SQL DML statements as they are executed

Note: This Question is unanswered, help us to find answer for this one

26. Which of the following statement is NOT true?

Answer

Correct Answer: The load() method returns null, when the unique id could not found in the database

Note: This Question is unanswered, help us to find answer for this one

27. Which one of the following statements is NOT true about using annotation mapping Entity hierarchies?

Answer

Correct Answer: The @DiscriminatorValue doesn't have default value and must be defined.

Note: This Question is unanswered, help us to find answer for this one

28. Which of the following does NOT correctly describe LockMode.NONE?

Answer

Correct Answer: If an object is requested with this lock mode, a WRITE lock will be obtained if it is necessary to actually read the state from the database

Note: This Question is unanswered, help us to find answer for this one

29. Which of the following statements is NOT true about mapping one class to multiple tables using annotation?

Answer

Correct Answer: The @PrimaryKeyJoinColumn annotation specifies the primary key of the primary table

Note: This Question is unanswered, help us to find answer for this one

30. Which of the following is NOT true about Second Level Cache?

Answer

Correct Answer: By default it effectively holds on to the identifiers for an individual query

Note: This Question is unanswered, help us to find answer for this one

31. Which one of the following statements is NOT true about HQL joins?

Answer

Correct Answer: Path navigation from one entity is a form of outer join.

Note: This Question is unanswered, help us to find answer for this one

32. Which of the following statements is true about using cache in Hibernate?

Answer

Correct Answer: The iterate()method of the Session and Query interfaces is provided to take advantage of second-level cache.

Note: This Question is unanswered, help us to find answer for this one

33. Which one of the following statements is true about using annotation to setup Inheritance Models?

Answer

Correct Answer: the @DiscriminatorValue annotation is used to specify the value in the in the discriminator column in database

Note: This Question is unanswered, help us to find answer for this one

34. Which one of the following statements is NOT true about Hibernate's cascading persistence?

Answer

Correct Answer: cascade="save-update" is the default setup in hibernate

Note: This Question is unanswered, help us to find answer for this one

35. Which of the following is NOT true about Hibernate OGM (still being developed)?

Answer

Correct Answer: It is expected to be used to interact with all NoSQL solution in all use cases

Note: This Question is unanswered, help us to find answer for this one

36. Which one of the following statements is NOT true about using components in Hibernate?

Answer

Correct Answer: Hibernate component is the lowest level of unit and cannot own other component

Note: This Question is unanswered, help us to find answer for this one

37. Which one of the following statements is NOT true about many to many relationship mapping?

Answer

Correct Answer: The @JoinTable annotation must be defined on the reverse side of the many to many relation ship

Note: This Question is unanswered, help us to find answer for this one

38. Which one of the following statements is NOT true about entity lifecycle events?

Answer

Correct Answer: If the timestamp of the most recent update made to the queried table is early than the timestamp of the cached query results, then the cached results are discarded

Note: This Question is unanswered, help us to find answer for this one

39. Object-oriented languages represent data as a ____ of objects

Answer

Correct Answer: graph

Note: This Question is unanswered, help us to find answer for this one

40. Which one of the following statements is true about how Hibernate retrieves an object?

Answer

Correct Answer: HQL Hibernate Query Language is a full object oriented query language

Note: This Question is unanswered, help us to find answer for this one

41. Which of the following is NOT a valid caching strategy?

Answer

Correct Answer: Write-only

Note: This Question is unanswered, help us to find answer for this one

42. Which of the following is NOT true about First Level Cache?

Answer

Correct Answer: It loads objects and make them available to the entire application

Note: This Question is unanswered, help us to find answer for this one

43. Which one of the following statements is NOT true about embedded objects?

Answer

Correct Answer: The @AttributeOverride annotation defines what type the database uses to save the embeddable field

Note: This Question is unanswered, help us to find answer for this one

44. Their are five mismatches that occur when storing objects in relational database:granularity,inheritance,identity,associations and

Answer

Correct Answer: navigation

Note: This Question is unanswered, help us to find answer for this one

45. Which of the following is used by Hibernate to redirect the logging output to preferred logging frameworks?

Answer

Correct Answer: Simple Logging Facade for Java (SLF4J)

Note: This Question is unanswered, help us to find answer for this one

46. Which one of the following statement is true about the following query: FROM Item AS item WHERE item.description like ? AND item.date > ?

Answer

Correct Answer: The as keyword is optional

Note: This Question is unanswered, help us to find answer for this one

47. Which one of the following statements is true?

Answer

Correct Answer: The load() method can return a poxy than immediately hitting the database.

Note: This Question is unanswered, help us to find answer for this one

48. Which one of the following statements is NOT true about hibernate Session?

Answer

Correct Answer: Hibernate can detect changes to the objects and make updates to the database automatically even if changes are made within the same session.

Note: This Question is unanswered, help us to find answer for this one

49. Which of the following is an INVALID LockMode?

Answer

Correct Answer: UPDATE

Note: This Question is unanswered, help us to find answer for this one

50. Which of the following statement is TRUE about sorting in Hibernate?

Answer

Correct Answer: A sorted collection is sorted in-memory using java comparator, while order collection is ordered at the database level using order by clause

Note: This Question is unanswered, help us to find answer for this one

51. Which of the following is NOT true about default flush operation in Hibernate?

Answer

Correct Answer: Hibernate NEVER flushes by default

Note: This Question is unanswered, help us to find answer for this one

52. Which one of the following statements is NOT true about comparison operator in HQL?

Answer

Correct Answer: You can use = NULL to test whether the value is null

Note: This Question is unanswered, help us to find answer for this one

53. Which one of the following statement is NOT true about Hibernate's Query interface?

Answer

Correct Answer: If the query returns more than result for the uniqueResult() method, the first one will be returned.

Note: This Question is unanswered, help us to find answer for this one

54. Which of the following is the FIRST Hibernate object that is created in any Hibernate application?

Answer

Correct Answer: Configuration

Note: This Question is unanswered, help us to find answer for this one

55. Which one of the following statements is NOT true about persistence annotations?

Answer

Correct Answer: The @Column annotations is used to specify the column name of the foreign key

Note: This Question is unanswered, help us to find answer for this one

56. Which of the following is NOT true about Session and Transaction scope in Hibernate?

Answer

Correct Answer: Multiple instances of SessionFactory are created, usually on application startup, from a Configuration instance

Note: This Question is unanswered, help us to find answer for this one

57. Hibernate offers an implementation of which specification?

Answer

Correct Answer: JPA

Note: This Question is unanswered, help us to find answer for this one

58. Which of the following is NOT a type of hibernate cache?

Answer

Correct Answer: SQL cache

Note: This Question is unanswered, help us to find answer for this one

59. Which one of the following statements is NOT true about named queries?

Answer

Correct Answer: The named query must be HQL strings. Native SQL is not supported in named query

Note: This Question is unanswered, help us to find answer for this one

60. Which one of the following statements is NOT true about ordering query result?

Answer

Correct Answer: You cannot order query results by more than one properties

Note: This Question is unanswered, help us to find answer for this one

61. Which one of the following statements is true about the instance states?

Answer

Correct Answer: Detached instants can be made persistent by calling saveOrUpdate()

Note: This Question is unanswered, help us to find answer for this one

62. Which of the following is NOT a valid value for 'hbm2ddl.auto' property in hibernate configuration?

Answer

Correct Answer: truncate

Note: This Question is unanswered, help us to find answer for this one

63. Which of the following provides an interface between application and data stored in the database?

Answer

Correct Answer: Session

Note: This Question is unanswered, help us to find answer for this one

64. Which of the following elements is used to declare the persistent class in Hibernate configuration file?

Answer

Correct Answer: <mapping>

Note: This Question is unanswered, help us to find answer for this one

65. Which one of the following statement is NOT true about SessionFactory?

Answer

Correct Answer: One SessionFactory can manage more than one database

Note: This Question is unanswered, help us to find answer for this one

66. Which one of the following statements is true about detached instance?

Answer

Correct Answer: A persistent instance will become detached after the session is closed.

Note: This Question is unanswered, help us to find answer for this one

67. Which of the following are valid Hibernate interceptors?

Answer

Correct Answer: Both Session-scoped and SessionFactory-scoped

Note: This Question is unanswered, help us to find answer for this one

68. Which of the following property needs to be defined to activate second-level caching?

Answer

Correct Answer: cache.provider_class

Note: This Question is unanswered, help us to find answer for this one

69. Which of the following property makes hibernate to generate SQL as per the chosen database?

Answer

Correct Answer: dialect

Note: This Question is unanswered, help us to find answer for this one

70. Which of the following is a VALID key component of Hibernate Configuration?

Answer

Correct Answer: Both database connection and class mapping setup

Note: This Question is unanswered, help us to find answer for this one

71. Which of the following correctly describes Hibernate Envers?

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

72. The ____ element is used to link data to the database.

Answer

Correct Answer: <property>

Note: This Question is unanswered, help us to find answer for this one

73. Which of the followings might be able to solve N+1 problem?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

74. The configuration object class is used to create a(n) ____?

Answer

Correct Answer: SessionFactory

Note: This Question is unanswered, help us to find answer for this one

75. A/an ______ is a primitive data type.

Answer

Correct Answer: Integer

Note: This Question is unanswered, help us to find answer for this one

76. A _______ represents a measure of work done in the database.

Answer

Correct Answer: transaction

Note: This Question is unanswered, help us to find answer for this one

77. Databases represent data in a ____ format.

Answer

Correct Answer: tabular

Note: This Question is unanswered, help us to find answer for this one

78. Hibernate takes care of mapping Java to the database using ___?

Answer

Correct Answer: XML

Note: This Question is unanswered, help us to find answer for this one

79. The reason for Hibernate is because their is a mismatch or impedance between the object model and the ____?

Answer

Correct Answer: relational database

Note: This Question is unanswered, help us to find answer for this one

80. An ORM solution should consist of which of the following functions:

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

81. Which of the following is TRUE about Hibernate Search?

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

82. SessionFactory is _____.

Answer

Correct Answer: thread safe

Note: This Question is unanswered, help us to find answer for this one

83. If Hibernate does not commit the transaction it can _______.

Answer

Correct Answer: rollback

Note: This Question is unanswered, help us to find answer for this one

84. Hibernate is a high performance ORM. ORM stands for?

Answer

Correct Answer: object relational mapping

Note: This Question is unanswered, help us to find answer for this one

85. Java is a/an _____ language

Answer

Correct Answer: Object-Oriented

Note: This Question is unanswered, help us to find answer for this one

86. What instructs Hibernate how to map the classes to the database?

Answer

Correct Answer: XML mapping file

Note: This Question is unanswered, help us to find answer for this one

87. The createhibernate.cfg.xml is a/an ____ configuration file.

Answer

Correct Answer: XML

Note: This Question is unanswered, help us to find answer for this one

88. Which of the following shortcomings are addressed by Hibernate Search?

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

89. Which is true:

Answer

Correct Answer: Session.Close();

Note: This Question is unanswered, help us to find answer for this one

90. A persistent framework is a(n) ____ service that stores and gets objects into a database.

Answer

Correct Answer: ORM

Note: This Question is unanswered, help us to find answer for this one

91. Which of the following XML elements is true for Hibernate?

Answer

Correct Answer: <hibernate-mapping>

Note: This Question is unanswered, help us to find answer for this one

92. Which of the following statements are true about Hibernate catching:

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

93. Hibernate will assume an instance is an unsaved transient instance if:

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one