0% found this document useful (0 votes)
29 views7 pages

Quiz 5 - 1

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)
29 views7 pages

Quiz 5 - 1

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

Question 1 (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 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.

c) Forces a class to be serializable.

d) It is for Hibernate only and it is not applicable in JPA.

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")

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 3 options:

a) No need because by default nothing can be null.

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")

b) None, enum is not supported.

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

You might also like