wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Spring Data JPA

Total questions: 20

Worksheet time: 10mins

Name
Class
Date
1.

What is the main goal of Object-Relational Mapping (ORM)?

a)

Encrypt data in the database

b)

Map Java objects to database tables

c)

Convert Java to SQL manually

d)

Replace SQL completely

2.

Which annotation is used to mark a class as a JPA entity?

a)

@Bean

b)

@Entity

c)

@Component

d)

@Table

3.

What does @Table(name="employee") specify in an entity class?

a)

Database name

b)

Column name

c)

Table name

d)

Schema name

4.

What is the purpose of @Column(name="emp_id")?

a)

It maps an entity to a table

b)

It maps a field to a specific column in the table

c)

It sets primary key

d)

It defines table constraints

5.

Which annotation marks a field as the primary key in a JPA entity?

a)

@Column

b)

@GeneratedValue

c)

@Id

d)

@PrimaryKey

6.

Which JPA strategy allows the database to automatically generate primary key values?

a)

AUTO_INCREMENT

b)

@Generated

c)

GenerationType.IDENTITY

d)

@AutoKey

7.

Which method in EntityManager is used to save a new entity to the database?

a)

store()

b)

insert()

c)

persist()

d)

save()

8.

What does the EntityManager.find() method do?

a)

Deletes the entity

b)

Retrieves an entity by its primary key

c)

Updates the entity

d)

Maps table to class

9.

Which of the following is NOT a valid GenerationType in JPA?

a)

IDENTITY

b)

AUTO

c)

SEQUENCE

d)

UUID

10.

What is the default fetch type for @ManyToOne relationships in JPA?

a)

LAZY

b)

EAGER

c)

DEFAULT

d)

NONE

11.

What is the main difference between JPA and Hibernate?

a)

JPA is a framework, Hibernate is a specification

b)

JPA is a specification, Hibernate is its implementation

c)

JPA is used in Python, Hibernate in Java

d)

No difference

12.

What does @Bean annotation do in Spring context?

a)

Declares a component

b)

Marks a method to return a bean managed by Spring

c)

Maps a column to a class

d)

Declares a service

13.

What is the scope of an entity in Hibernate once persisted using EntityManager?

a)

JVM-wide

b)

Global

c)

Attached to the persistence context

d)

Stateless

14.

What is the purpose of @GeneratedValue(strategy = GenerationType.IDENTITY)?

a)

Uses application to generate the primary key

b)

Allows the database to auto-generate primary key using identity column

c)

Uses UUID for key generation

d)

Automatically generates unique constraint

15.

What type of relationship is defined by @OneToMany annotation?

a)

One object can map to many rows

b)

Many classes mapped to one table

c)

One entity is related to many instances of another entity

d)

One column to many columns

16.

What does @Entity annotation require to work correctly?

a)

A @Column on each field

b)

A class-level @Table

c)

A field with @Id

d)

A no-argument constructor

17.

Which of the following is true about EntityManager?

a)

It is part of Spring Boot

b)

It is a Hibernate-only feature

c)

It manages the lifecycle of entities

d)

It is used only for JDBC

18.

What does ORM stand for?

a)

Object Relational Mapper

b)

Object Resource Method

c)

Oracle Relational Model

d)

Object Repository Manager

19.

In which package is @Entity annotation located?

a)

org.springframework.stereotype

b)

org.hibernate.annotations

c)

javax.persistence

d)

java.persistence.entity

20.

Which interface provides CRUD operations in JPA?

a)

CrudInterface

b)

EntityManager

c)

JdbcTemplate

d)

JpaEntity