Quiz 3 - 1
Quiz 3 - 1
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.html
Question 1 options:
a) @NamedQuery
b) @Id
c) @Table
d) @Entity
Question 2 (1 point)
Saved
Assume some code is written to execute a simple select only query on the DB. If this code is
written in the style of Hibernate, there must be call to session.beginTransaction(). Starting a
transaction is not needed in case of code written in the style of JPA when doing simple select
only query. Hint: Look at and
compare HibernateExample.java and JPAExample.java programs given in Week 4.
Question 2 options:
a) True
b) False
Question 3 (1 point)
Saved
Which annotation is used to identify an instance variable which corresponds to the primary key
of a mapped table on the database. This annotation is only used for single-column primary key.
Read online documentation: https://docs.oracle.com/javaee/7/api/javax/persistence/Id.html
Question 3 options:
a) @Column
b) @Id
c) @Basic
d) @GeneratedValue
Question 4 (1 point)
Saved
Hibernate uses JDBC to connect to the database.
Question 4 options:
a) True
b) False
Question 5 (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 5 options:
a) context.xml
b) web.xml
c) hibernate.cfg.xml
d) persistence.xml
Question 6 (1 point)
Saved
Hibernate sits between the database and Java application. It is an implementation of JPA.
Question 6 options:
a) True
b) False
Question 7 (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 7 options:
a) @Id
b) @Column
c) @Basic
d) @GeneratedValue
Question 8 (1 point)
Saved
What is true about the @Table annotation? Read the online documentation:
https://docs.oracle.com/javaee/7/api/javax/persistence/Table.html
Question 8 options:
a) It allows you to define the name, schema, and catalog of the table for your entity mapping.
b) 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.
Question 9 (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/GeneratedValue.html
Question 9 options:
a) @Basic
b) @Id
c) @Column
d) @GeneratedValue
Question 10 (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/Transient.html
Question 10 options:
d) It specifies that the field or property is to be mapped to a column on a table in the database.