Quiz 5 - 1
Quiz 5 - 1
Saved
Given the code below, what will be the column type in the DB? Assume that the table is
generated by JPA and that SomeEnum is an enum type.
@Enumerated(EnumType.ORDINAL)
@Column(name = "COL_SOMETHING")
Question 1 options:
a) NVARCHAR
b) VARCHAR
c) BIT
d) int
Question 2 (1 point)
Saved
What is the purpose of @Entity?
Question 2 options:
a) All are true.
b) Let JPA know that the class is to be considered as an entity and that it needs to be mapped to a table in DB.
Question 3 (1 point)
Saved
Assume we have the code below, which annotation prevents "foo" from being null?
@Entity(name = "A")
@Table(name = "TABLE_A")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "COL_1")
protected String foo;
public APojo() {
Question 3 options:
b) @Basic(optional=true)
c) @Basic
d) @Basic(optional=false)
Question 4 (1 point)
Saved
By default, all fields or properties in an entity are considered to be @Basic which means they
are nullable. Read: https://docs.oracle.com/javaee/7/api/javax/persistence/Basic.html
Question 4 options:
a) True
b) False
Question 5 (1 point)
Saved
There is no difference in starting/initializing JPA in Java SE vs Java EE.
Question 5 options:
a) True
b) False
Question 6 (1 point)
Saved
What annotation is used if enum type field/property is used in an entity?
Question 6 options:
a) @Column(name="enum")
c) @Temporal
d) @Enumerated
Question 7 (1 point)
Saved
Which annotation maps the primary key field/property of an entity to the primary key column of
a table?
Question 7 options:
a) GenerationType.IDENTITY
b) @Column(name = "ID")
c) @GeneratedValue
d) @Id
Question 8 (1 point)
Saved
If there is a version conflict when trying to commit updates of an instance of an entity,
an OptimisticLockException will be thrown by JPA.
Question 8 options:
a) True
b) False
Question 9 (1 point)
Saved
Which annotations prevents a field or property in an entity to be mapped/persisted?
Question 9 options:
a) @Transient
b) @Id
c) @EmbeddedId
d) @Basic
Question 10 (1 point)
Saved
What is the recommended GenerationType for MySQL? Read: https://vladmihalcea.com/why-
should-not-use-the-auto-jpa-generationtype-with-mysql-and-hibernate/
Question 10 options:
a) GenerationType.SEQUENCE
b) GenerationType.TABLE
c) GenerationType.AUTO
d) GenerationType.IDENTITY