0% found this document useful (0 votes)
17 views6 pages

Quiz 5 - 2

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)
17 views6 pages

Quiz 5 - 2

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/ 6

Quiz 05 – JPA

Question 1 (1 point)
Saved
What annotation is used if enum type field/property is used in
an entity?
Question 1 options:

a) @Temporal

b) @Column(name="enum")

c) None, enum is not supported.

d) @Enumerated

Question 2 (1 point)
Saved
There is no difference in starting/initializing JPA in Java SE vs
Java EE.
Question 2 options:
a) True
b) False
Question 3 (1 point)
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")

protected SomeEnum foo;

Question 3 options:
a) NVARCHAR

b) BIT

c) int

d) VARCHAR

Question 4 (1 point)
Saved
Assume we have the code below, which annotation prevents
"foo" from being null?
@Entity(name = "A")

@Table(name = "TABLE_A")

public class APojo {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

protected int id;

@Column(name = "COL_1")

protected String foo;

//JPA likes default constructor

public APojo() {

Question 4 options:

a) @Basic(optional=true)
b) No need because by default nothing can be null.

c) @Basic

d) @Basic(optional=false)

Question 5 (1 point)
Saved
Which annotation maps the primary key field/property of an
entity to the primary key column of a table?
Question 5 options:

a) GenerationType.IDENTITY

b) @Id

c) @Column(name = "ID")

d) @GeneratedValue

Question 6 (1 point)
Saved
Which annotations prevents a field or property in an entity to
be mapped/persisted?
Question 6 options:

a) @EmbeddedId

b) @Id

c) @Transient

d) @Basic
Question 7 (1 point)
Saved
In @Column annotation below, how do we set it up to use
Oracle's NVARCHAR unicode-aware column-type?
@Entity(name = "H")

@Table(name = "TABLE_H")

public class HPojo {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

protected int id;

@Column(name = "COL_SOMETHING")

protected String foo;

// JPA likes default constructor

public HPojo() {

Question 7 options:

a) By default, all string mappings support Unicode.

b) columnDefinition="VARCHAR(100)"

c) columnDefinition="VARCHAR"

d) columnDefinition="NVARCHAR"

Question 8 (1 point)
Saved
What is the purpose of the @Version annotation placed on a
field of an entity?
Question 8 options:

a) It is for the version of code which has updated the data, for example, code written in JDK 11 will have
version 11 on the DB.

b) It prevents simultaneous updates of a row in a table. Each update increments the version, hence
preventing old versions from updating newer versions.

c) It represents the version of the table, as to how many times it has been dropped and recreated.

Question 9 (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 9 options:
a) True
b) False
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.AUTO

b) GenerationType.TABLE

c) GenerationType.SEQUENCE
d) GenerationType.IDENTITY

You might also like