Olete.in
Articles
Mock Tests
🧪 Hibernate MCQ Quiz Hub
Hibernate Mcq Set 1
Choose a topic to test your knowledge and improve your Hibernate skills
1. Which of the following methods hits database always?
load()
loadDatabase()
getDatabase()
get()
2. Select the inheritance model which is NOT available in Hibernate
Tables Per Concrete Class
Table Per class hierarchy
Table Per sub-class
Table Per Object
3. Which method is easy for a Java programmer to add a criterion?
HCQL
HQL
SQL
None of the above
4. Which of the following are most common configuration methods of Hibernate Configuration
XML Configuration hibernate.cfg.xml
Mapping files and XML Configuration hibernate.cfg.xml
web.config
http.conf
5. Which of the following is true about transient state of a persistent entity?
A new instance of a persistent class which is not associated with a Session
A new instance of a persistent class which has no representation in the database
A new instance of a persistent class which has no identifier value
All of the above
6. Which of the following are tags of hibernate.cfg.xml?
SQL variant to generate
DTD
JDBC connection
All of these
7. To persist collections of embeddable type, hibernates uses
OneToMany
ElementCollection
Both A and B
None
8. Which of the following is not an inheritance mapping strategies?
Table per hierarchy
Table per concrete class
Table per subclass
Table per class
9. Which of the following is FALSE about Session in hibernate
Session is a lightweight non-threadsafe object
You can share the session between threads
Session represents a single unit-of-work with the database
Session is the primary interface for the persistence service
10. Which of the following is true about query level cache in hibernate?
Query level cache is an optional feature
Query level cache requires two additional physical cache regions that hold the cached query results and the timestamps when a table was last updated
Query level cache is only useful for queries that are run frequently with the same parameters
All of the above
11. The QBC stands for
Query By Call
Query By Column
Query By Criteria
Query By Code
12. If a single table hosts all the instances of a class hierarchy, then it is known as
Joined subclass strategy
Single table per class hierarchy strategy
Both
None of these
13. Select the design pattern that should be followed while creating SessionFactory in hibernate?
Singleton
Prototype
Both
None
14. The Hibernate XML configuration file name is?
hibernate.cfg.xml
hibernate.config.xml
hibernate.cg.xml
None of the mentioned
15. What does hibernate.hbm2ddl.auto create this means?
create tables automatically
create session object automatically
create Session Factory object automatically
None of these
16. In which file database table configuration is stored?
.dbm
.hbm
.ora
.sql
17. Which of the following is not a Session method?
Session.save()
Session.remove()
Session.saveorupdate()
Session.persist()
18. What does "" means?
generate primary key
generate tables based on configuration
generate sql statement on configuration
None of these
19. Which statement is correct?
Only the Session that you obtained with sf.getCurrentSession() is flushed and closed automatically
Only the Session that you obtained with sf.openSession() is flushed and closed automatically
Only the Session that you obtained with sf.getNewSession() is flushed and closed automatically
None of the above
20. In the elements of Hibernate architecture is a factory of session and client of ConnectionProvider,It holds second level cache (optional) of data?
Connection Provider
Session
Session Factory
Transaction
21. Which of the following is not a core interface of Hibernate?
Configuration
Criteria
SessionManagement
Session
22. Which of the following methods returns proxy object?
loadDatabase()
getDatabase()
load()
get()
23. Which of the following method is used inside session only?
merge()
update()
end()
kill()
24. Which of the following is not a state of object in Hibernate?
Attached()
Detached()
Persistent()
Transient()
25. Which of the following is not an advantage of using Hibernate Query Language?
Database independent
Easy to write query
No need to learn SQL
Difficult to implement
26. Which of the following is not an advantage of Hibernate Criteria API?
Allows to use aggregate functions
Cannot order the result set
Allows to fetch only selected columns of result
Can add conditions while fetching results
27. Which of the following is not a core component of Hibernate?
JDBC
SessionFactory
Session
Configuration
28. Which of the following is true about detached state of a persistent entity?
Once we close the Hibernate Session, the persistent instance will become a detached instance.
A new instance of a persistent class which is not associated with a Session.
You can make a transient instance detached by associating it with a Session.
None of the above.
29. Which of the following elements is used to define specific mappings from a Java classes to the database tables?
property
hibernate-config
class
class-config
30. Which of the following element maps java.util.Map property in hibernate?
<set>
<list>
<bag>
<map>
31. Which of the following element is used to represent many-to-many relationship in hibernate?
<many-to-many>
<many-many>
<ManyToMany>
None of the above.
32. Which of the following database is not supported by Hibernate?
Oracle
Microsoft SQL Server Database
FoundationDB
Informix Dynamic Server
33. Which of the following is true about HQL?
Hibernate supports named parameters in its HQL queries.
HQL supports a range of aggregate methods, similar to SQL.
Both of the above.
None of the above.
Submit