What does session.createQuery("Query").scroll() return ?

  1. ListResultSet

  2. ResultSet

  3. ScrollableResultSet

  4. ScrollableResult


Correct Option: D
Explanation:

To understand what session.createQuery("Query").scroll() returns, the user needs to know about Hibernate and its query methods.

Hibernate is an ORM (Object-Relational Mapping) library that provides an interface between Java classes and SQL databases. It provides several query methods to interact with the database, including session.createQuery().

session.createQuery("Query").scroll() method is used to iterate over a large number of objects without loading them all into memory at once. It returns a ScrollableResults object that can be used to scroll through the results one at a time.

Now, let's go through each option and explain why it is right or wrong:

A. ListResultSet: This option is incorrect because there is no such class as ListResultSet in Hibernate.

B. ResultSet: This option is incorrect because session.createQuery("Query").scroll() does not return a ResultSet object. Hibernate uses a different interface called ScrollableResults for scrolling through large datasets.

C. ScrollableResultSet: This option is incorrect because there is no such class as ScrollableResultSet in Hibernate.

D. ScrollableResult: This option is correct. session.createQuery("Query").scroll() returns a ScrollableResult object that can be used to scroll through the results one at a time.

Therefore, the answer is: D. ScrollableResult.

Find more quizzes: