Hibernate Flashcards

1
Q
\_\_\_\_\_\_ fetching loads child records ahead of time, whereas \_\_\_\_\_\_ fetching only loads child records on-demand.
Select one:
a. Lazy, Eager
b. Cascade, Eager
c. Eager, Lazy 
d. Lazy, Cascade
A

c. Eager, Lazy

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

________ ensures the SQL only contains columns whose state have changed, and _________ ensures SQL only contains columns whose values are not null.
Select one:
a. Automatic dirty checking, transactional write-behind
b. Dynamic-insert, dynamic-update
c. Dynamic-update, dynamic-insert
d. Transactional write-behind, automatic dirty checking

A

c. Dynamic-update, dynamic-insert

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

An object in transient state in hibernate is linked to the database.
Select one:
A. TRUE
B. FALSE

A

B. FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

by default, lazy loading is enabled in Hibernate for collections
Select one:
A. TRUE
B. FALSE

A

A. TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Criteria API can be used to store data in the database.
Select one:
A. TRUE
B. FALSE

A

B. FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

ehCache is a L2 Cache provider for Hibernate.
Select one:
A. TRUE
B. FALSE

A

A. TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
For the whole application, there will be generally one \_\_\_\_\_\_\_\_\_ and can be shared by all the application threads.
Select one:
a. Session 
b. SessionFactory
c. Transaction
d. Query
A

b. SessionFactory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
Hibernate bootstrapping is performed by which core interface?
Select one:
a. Session
b. Configuration
c. SessionFactory
d. Transaction
A

b. Configuration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Hibernate is a DAO framework, not an ORM framework
Select one:
A. TRUE
B. FALSE

A

B. FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Hibernate is classified under the Presentation layer in the J2EE architecture
Select one:
A. TRUE
B. FALSE

A

B. FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can we have Hibernate write the generated SQL to the console?
Select one:
a. property name=show_sql in hibernate.cfg.xml
b. ShowSQL annotation in POJO mappings
c. Pass the System.out OutputStream to the CRUD method as a parameter
d. property name=show_sql in mapping.hbm.xml

A

a. property name=show_sql in hibernate.cfg.xml

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How can you define a sequence generated primary key in Hibernate?
Select one:
a. Using the generator tag in HBM or the GeneratedValue annotation
b. Using the generated tag in HBM or the GeneratedValue annotation
c. Using the sequence tag in HBM or the Sequence annotation
d. Using the sequence tag in HBM or the GeneratedValue annotation

A

a. Using the generator tag in HBM or the GeneratedValue annotation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

HQL is the object oriented version of SQL and it works with Entity class names rather than table names.
Select one:
A. TRUE
B. FALSE

A

A. TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

L2 Cacheing is specific to a SessionFactory rather than a Session object.
Select one:
A. TRUE
B. FALSE

A

A. TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

mapping class tag is used to map an hbm.xml file in Hibernate.cfg.xml.
Select one:
A. TRUE
B. FALSE

A

B. FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

session-factory is a tag in hibernate.cfg.xml.
Select one:
A. TRUE
B. FALSE

A

A. TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q
The \_\_\_\_\_\_ instance state refers to an object not associated with any data. A \_\_\_\_\_\_\_\_ state means an object is associated with data within the session. After the session is closed, the object changes to the \_\_\_\_\_\_\_\_ state.
Select one:
a. Detached, Persisted, Salient
b. Transient, Persistent, Detached
c. Persisted, Salient, Detached
d. Detached, Persistent, Transient
A

b. Transient, Persistent, Detached

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
The \_\_\_\_\_\_ interface allows developers to write and execute HQL.
Select one:
a. Query
b. Criteria 
c. Session
d. HQL
A

a. Query

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q
The \_\_\_\_\_\_\_\_\_\_\_\_ transaction isolation level addresses none of the concurrency issues.
Select one:
a. Read uncommitted 
b. Read committed
c. Repeatable read
d. Serializable
A

a. Read uncommitted

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q
The \_\_\_\_\_\_\_\_\_\_\_\_ transaction isolation level addresses the dirty read concurrency issue.
Select one:
a. Read uncommitted
b. Serializable
c. Repeatable read
d. Read committed
A

d. Read committed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q
The \_\_\_\_\_\_\_\_\_\_\_\_ transaction isolation level addresses the phantom read concurrency issue.
Select one:
a. Read uncommitted
b. Read committed
c. Serializable
d. Repeatable read
A

c. Serializable

22
Q
The \_\_\_\_\_\_\_\_\_\_\_\_ transaction isolation level addresses the unrepeatable read concurrency issue.
Select one:
a. Read committed
b. Repeatable read
c. Serializable 
d. Read uncommitted
A

b. Repeatable read

23
Q

The atomic property of a database transaction means
Select one:
a. Multiple statements executed as one unit of work will pass or fail together.. all or nothing
b. Each statement executes and commits data serially
c. Each statement holds database locks at the finest level of granularity
d. All of the above

A

a. Multiple statements executed as one unit of work will pass or fail together.. all or nothing

24
Q
The basic interface for all Hibernate applications is the \_\_\_\_\_\_\_\_. The instances are light weighted and can be created and destroyed without expensive process.
Select one:
a. Session
b. SessionFactory
c. All of the above
d. Configuration
A

a. Session

25
Q

The consistent property of a database transaction means
Select one:
a. Any transaction will leave the data in a consistent state and rollback if the transaction fails
b. Transactions have consistent behavior, meaning they execute the same SQL statements
c. Transactions consistently avoid the use of cascades, triggers, and constraints
d. All of the above

A

a. Any transaction will leave the data in a consistent state and rollback if the transaction fails

26
Q

The durable property of a database transaction means
Select one:
a. Committed data will remain persisted regardless of power loss, system crash, or other fatal errors
b. Transactions are recorded in non-volatile, secondary storage
c. All of the above
d. RAID configuration ensures data mirroring for 100 percent redundancy

A

c. All of the above

27
Q

The get method in hibernate throws an exception when the object is not found in the database.
Select one:
A. TRUE
B. FALSE

A

B. FALSE

28
Q

The isolated property of a database transaction means
Select one:
a. Concurrent transactions provide the same results that would be found if transactions were executed one-by-one
b. Transactions execute in a serialized, first-in first-out fashion
c. All of the above
d. Concurrent transactions occur within a separate database schema, isolated from one another

A

d. Concurrent transactions occur within a separate database schema, isolated from one another

29
Q

The load method in Hibernate reads data from the database directly.
Select one:
A. TRUE
B. FALSE

A

B. FALSE

30
Q

The load method will ______ if the record is not found, whereas get will _______.
Select one:
a. Throw an exception, throw an exception
b. Return null, return null
c. Throw an exception, return null
d. Return null, throw an exception

A

c. Throw an exception, return null

31
Q
This core Hibernate interface is used to commit and rollback changes to the state of persistent data.
Select one:
a. Session
b. Transaction 
c. Query
d. SessionFactory
A

b. Transaction

32
Q
Use \_\_\_\_\_\_\_ if you are sure that the session does not contain an already persistent instance with the same identifier, and \_\_\_\_\_\_\_ if you want to force Hibernate to save your modifications at any time without consideration of the state of the session.
Select one:
a. Update, merge
b. Merge, SaveOrUpdate
c. Merge, update 
d. Join, merge
A

a. Update, merge

33
Q
What important information is not stored in the hibernate.cfg.xml file?
Select one:
a. JDBC connection configuration 
b. Mapping files
c. SQL dialect variant
d. One-to-many mappings
A

d. One-to-many mappings

34
Q
What is an HBM file?
Select one:
a. None of the above
b. Maps tables to objects and maps table relationships 
c. Configures the SessionFactory
d. Configures your cache properties
A

b. Maps tables to objects and maps table relationships

35
Q

What is automatic dirty checking?
Select one:
a. Hibernate updates the object when the database state changes
b. Hibernate performs dirty reads and can do this within Read committed mode
c. Hibernate updates the database when we modify the state of an object inside a transaction
d. All of the above

A

c. Hibernate updates the database when we modify the state of an object inside a transaction

36
Q

What is HQL?
Select one:
a. The same as SQL but allows some short-hand notation
b. A Java Persistence API (JPA) standard that Hibernate enforces through a consistent query language
c. An object-oriented extension to SQL, which refers to beans and properties instead of tables and columns
d. None of the above

A

c. An object-oriented extension to SQL, which refers to beans and properties instead of tables and columns

37
Q
What is not a type of inheritance model in Hibernate?
Select one:
a. Table per class hierarchy
b. Table per subclass 
c. Table per abstract class
d. Table per concrete class
A

c. Table per abstract class

38
Q

What is not true about Hibernate?
Select one:
a. Maps database tables to Java classes via XML or annotations
b. Considered within the light objects mapping ORM level
c. An object-relational mapping framework for Java
d. Provides CRUD operations to relieve developers from writing more SQL

A

b. Considered within the light objects mapping ORM level

39
Q

What is the difference between level 1 (L1) and level 2 (L2) caching?
Select one:
a. L1 cache is default, while L2 cache is optional
b. All of the above
c. L2 cache uses EHCache, OSCache, and other plugins for configuration
d. L1 cache is session-scoped, while L2 cache is formed by the SessionFactory

A

b. All of the above

40
Q

What is the difference between sorting and ordering collections in Hibernate?
Select one:
a. Sorting uses Java collections sorting, and ordering uses the SQL order by clause
b. Ordering uses Java collections sorting, and sorting uses the SQL order by clause
c. Sorting is slower when the collection is small
d. Ordering is slower when the collection is large

A

a. Sorting uses Java collections sorting, and ordering uses the SQL order by clause

41
Q

What is the purpose of the Criteria interface?
Select one:
a. Fully object-oriented programmatic query creation
b. None of the above
c. Higher optimization of your HQL queries
d. Execute native SQL in your code

A

a. Fully object-oriented programmatic query creation

42
Q

What is transactional write-behind?
Select one:
a. Hibernate automatically avoids foreign key constraints when manipulating data
b. All of the above
c. Hibernate writes the state of the object after the transaction is committed
d. Hibernate updates the database when we modify the state of an object inside a transaction

A

a. Hibernate automatically avoids foreign key constraints when manipulating data

43
Q
When using Criteria, \_\_\_\_\_\_\_\_\_ adds a WHERE clause, and \_\_\_\_\_\_\_\_\_ adds an aggregate function.
Select one:
a. Restrictions, Projections 
b. Restrictions, Aggregations
c. Where, Aggregate
d. Projections, Restrictions
A

a. Restrictions, Projections

44
Q
Which is not a common JPA annotation for POJO mappings?
Select one:
a. Bean 
b. Entity
c. OneToMany
d. Table
A

a. Bean

45
Q
Which is not one of the Hibernate-specific Collection types?
Select one:
a. Map
b. ArrayList 
c. Bag
d. List
e. Set
A

b. ArrayList

46
Q
Which of the following annotations is used to map a class with a table in the database?
Select one:
A. @Persistence
B. @Store
C. @Entity
A

C. @Entity

47
Q
Which of the following is not a collection type in Hibernate?
Select one:
A. Set
B. List
C. Bag
D. Queue
A

D. Queue

48
Q
Which of the following is not a property of a transaction?
Select one:
A. Atomic
B. Consistent
C. Integrity
D. Durable
A

C. Integrity

49
Q
Which of the following is not an interface in Hibernate
Select one:
A. Session
B. SessionFactory
C. Transaction
D. Connection
A

D. Connection

50
Q

You register an HBM file using ________ and an annotated POJO using __________ in the hibernate.cfg.xml?
Select one:
a. mapping resource=__, mapping class=__
b. mapping class=__, mapping class=__
c. mapping resource=__, mapping resource=__
d. mapping class=__, mapping resource=__

A

a. mapping resource=__, mapping class=__

51
Q
\_\_\_\_\_\_\_\_\_\_\_ represents a current development copy of a dependency.
Select one:
a. Version
b. Model Number
c. Artifact ID
d. SNAPSHOT
A

d. SNAPSHOT