0% found this document useful (0 votes)
5 views5 pages

Hibernate Quiz for Java Developers

Uploaded by

rita.jiang889
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Hibernate Quiz for Java Developers

Uploaded by

rita.jiang889
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Quiz 03 – Hibernate

Question 1 (1 point)
Saved
What annotation is needed to mark a class as an entity to be
mapped by Hibernate/JPA? Read the online documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Entity.h
tml
Question 1 options:

a) @NamedQuery

b) @Table

c) @Id

d) @Entity

Question 2 (1 point)
Saved
Select all the states of an entity in Hibernate? (All or nothing
grading style, select the correct answers only.)
Question 2 options:
UPDATE_MODEL_VALUES
Detached
Transient
Validation
Persistent
Question 3 (1 point)
Saved
What is the name of the file which stores the configuration for
JPA? Hint: Look inside the src/main/resources/META-
INF folder of the sample project Example-
HibernateJPA given in Week 4.
Question 3 options:

a) hibernate.cfg.xml

b) context.xml

c) persistence.xml

d) web.xml

Question 4 (1 point)
Saved
What is true about the @Table annotation? Read the online
documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Table.h
tml
Question 4 options:

a) If no @Table annotation is used, then default values are used, that is, the entity class MyEntity will be
mapped to the myentity table in the database if no @Table annotation is provided.

b) It allows you to define the name, schema, and catalog of the table for your entity mapping.

c) All answers are true.

Question 5 (1 point)
Saved
What does the annotation @Transient on a field or property of
an entity mean? Read online documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Transie
nt.html
Question 5 options:
a) All answers are wrong.

b) It specifies that the field or property is to be mapped to a column on a table in the database.

c) It specifies that the field or property is not persistent.

d) It specifies that the field or property can be null.

Question 6 (1 point)
Saved
Which annotation is used to let Hibernate/JPA know that the
primary key field or property of an entity is auto-generated?
Read online documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Genera
tedValue.html
Question 6 options:

a) @Column

b) @GeneratedValue

c) @Basic

d) @Id

Question 7 (1 point)
Saved
What is the name of the file which stores the configuration for
Hibernate? Hint: Look inside the src/main/resources folder
of the sample project Example-HibernateSE given in Week
4.
Question 7 options:

a) persistence.xml
b) web.xml

c) hibernate.cfg.xml

d) context.xml

Question 8 (1 point)
Saved
Hibernate uses JDBC to connect to the database.
Question 8 options:
a) True
b) False
Question 9 (1 point)
Saved
Which annotation is used to map an instance variable to its
column on a table in the DB. Read online documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Column
.html
Question 9 options:

a) @Column

b) @GeneratedValue

c) @Id

d) @Basic

Question 10 (1 point)
Saved
Hibernate sits between the database and Java application. It
is an implementation of JPA.
Question 10 options:
a) True
b) False

You might also like