Deck 27: Java Persistence Api Jpa

Full screen (f)
exit full mode
Question
The JPA annotation @Basic specifies whether the column is optional and whether the corresponding data should loaded ________ (i.e., only when the data is accessed through the entity object) or ________ (i.e., loaded immediately when the entity object is created).

A) lazily, actively
B) slowly, eagerly
C) lazily, eagerly
D) idly, actively
Use Space or
up arrow
down arrow
to flip the card.
Question
When you used JPA in this chapter, you interacted with an existing database via classes that the NetBeans IDE generated from the XE "database schema" database's schema. You used the NetBeans Entity Classes from Database… option to add to your project classes that represented the database tables. Together, these classes and the corresponding settings are known as a ________ unit.

A) perseverance
B) perpetual
C) sticky
D) persistence.
Question
The first argument to EntityManager's XE "EntityManager interface:createQuery method" XE "createQuery method of interface EntityManager" createQuery method is a String written in ________.

A) JPL
B) JavaQL
C) JPQL
D) None of the above.
Question
Which of the following statements related to JPA is false?

A) The Java Persistence API (JPA) maps Java classes to relational database tables and objects of those classes to rows in the tables. This is known as object-relational mapping.
B) You can use the NetBeans IDE's object-relational mapping tools to select a database and autogenerate classes that use JPA to interact with that database. Your programs can then use those classes to query the database, insert new records, update existing records and delete records.
C) Unlike JDBC, you will have to create mappings between your Java code and database tables, and you'll be able to perform complex database manipulations directly in Java.
D) JPA can be used with any database management system that supports JDBC.
Question
Which of the following JPA-related statements is false?

A) You can update an existing entity by modifying its entity object in the context of a transaction.
B) Once a transaction is committed, the changes to the entity are saved to the database.
C) You can delete an existing entity.
D) When you commit a transaction the entity is kept as a backup in the database.
Question
Which f the following JPA-related statements is false?

A) You can use XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager method XE "EntityManager interface:getTransaction method" XE "getTransaction method of interface EntityManager" getTransaction to get the EntityTransaction that manages the transaction.
B) You can use EntityTransaction method XE "EntityTransaction interface:begin method" XE "begin method of interface EntityTransaction" begin to start the transaction.
C) You can use XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager method apply to insert a new entity into the database.
D) You call EntityTransaction method XE "EntityTransaction interface:commit method" XE "commit method of interface EntityTransaction" commit to commit the changes to the database.
Question
In JPA transaction processing, if the operations execute successfully, you call EntityTransaction method _______ to commit the changes to the database. If any operation fails, you call EntityTransaction method ________ to return the database to its state prior to the transaction.

A) apply, rollback
B) commit, restore
C) apply, restore
D) commit, rollback
Question
Which of the following statements is false?

A) For certain types of projects, NetBeans automatically includes JPA support, but not for simple Java Application projects.
B) NetBeans projects do not include database drivers by default.
C) Each Java Enterprise Edition (Java EE) API-such as JPA-has a reference implementation that you can use to experiment with the API's features and implement applications.
D) The JPA reference implementation-which is included with the NetBeans Java EE version-is NetBeansLink.
Question
An object of type ________ is used to manage the data flow between the program and the database.

A) XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager
B) XE "Interfaces:EntityManagerFactory" XE "EntityManagerFactory interface" EntityManagerFactory XE "Classes:Persistence" XE "Persistence class"
C) Persistence
D) XE "Interfaces:TypedQuery" XE "TypedQuery interface" TypedQuery
Question
Which of the following JPA-related statements in false?

A) An object that implements the TypedQuery generic interface performs queries and returns a collection of matching entities.
B) To create queries, you can use EntityManager methods.
C) The Java Persistence Query Language (JPQL) is quite similar to SQL.
D) JPQL is optimized for dealing with relational database tables, rather than entity objects.
Question
For entity classes in JPA, an @NamedQueries annotation specifies a collection of ________ annotations that declare various named queries.

A) @Entity-Specifies that the class is an XE "entity class" entity class.
B) @Table-Specifies the entity class's corresponding database table.
C) @NamedQuery
D) None of the above.
Question
In JPA, when you compile the entity classes, the compiler looks at the annotations and adds JPA capabilities that help manage the interactions with the database-this is known as ________ capabilites.

A) implanting
B) injecting
C) infusing
D) instilling
Question
Which of the following statements about JPA database transaction processing is false?

A) Transaction processing enables a program that interacts with a database to treat a set of operations as a single operation. Such an operation also is known as an atomic operation or a transaction.
B) At the end of a transaction, a decision can be made either to commit the transaction or roll back the transaction.
C) Committing a transaction finalizes the database operation(s); all insertions, updates and deletions performed as part of the transaction cannot be reversed.
D) Rolling back the transaction leaves the database in its state prior to the database operation. This is useful when a portion of a transaction fails to complete properly.
Question
An object that implements the EntityManager ________ manages the interactions between a program and the database.

A) interface
B) class
C) enumeration
D) None of the above.
Question
With JPA, as part of a persistence unit, the IDE also creates a ________ package in the Source Packages folder.

A) META-DATA
B) PERSISTENCE-INF
C) PU
D) META-INF
Question
When you define a query in your own code, it's known as a(n) ________ query.

A) dynamic
B) static
C) active
D) passive
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/16
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 27: Java Persistence Api Jpa
1
The JPA annotation @Basic specifies whether the column is optional and whether the corresponding data should loaded ________ (i.e., only when the data is accessed through the entity object) or ________ (i.e., loaded immediately when the entity object is created).

A) lazily, actively
B) slowly, eagerly
C) lazily, eagerly
D) idly, actively
lazily, eagerly
2
When you used JPA in this chapter, you interacted with an existing database via classes that the NetBeans IDE generated from the XE "database schema" database's schema. You used the NetBeans Entity Classes from Database… option to add to your project classes that represented the database tables. Together, these classes and the corresponding settings are known as a ________ unit.

A) perseverance
B) perpetual
C) sticky
D) persistence.
persistence.
3
The first argument to EntityManager's XE "EntityManager interface:createQuery method" XE "createQuery method of interface EntityManager" createQuery method is a String written in ________.

A) JPL
B) JavaQL
C) JPQL
D) None of the above.
JPQL
4
Which of the following statements related to JPA is false?

A) The Java Persistence API (JPA) maps Java classes to relational database tables and objects of those classes to rows in the tables. This is known as object-relational mapping.
B) You can use the NetBeans IDE's object-relational mapping tools to select a database and autogenerate classes that use JPA to interact with that database. Your programs can then use those classes to query the database, insert new records, update existing records and delete records.
C) Unlike JDBC, you will have to create mappings between your Java code and database tables, and you'll be able to perform complex database manipulations directly in Java.
D) JPA can be used with any database management system that supports JDBC.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following JPA-related statements is false?

A) You can update an existing entity by modifying its entity object in the context of a transaction.
B) Once a transaction is committed, the changes to the entity are saved to the database.
C) You can delete an existing entity.
D) When you commit a transaction the entity is kept as a backup in the database.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
6
Which f the following JPA-related statements is false?

A) You can use XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager method XE "EntityManager interface:getTransaction method" XE "getTransaction method of interface EntityManager" getTransaction to get the EntityTransaction that manages the transaction.
B) You can use EntityTransaction method XE "EntityTransaction interface:begin method" XE "begin method of interface EntityTransaction" begin to start the transaction.
C) You can use XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager method apply to insert a new entity into the database.
D) You call EntityTransaction method XE "EntityTransaction interface:commit method" XE "commit method of interface EntityTransaction" commit to commit the changes to the database.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
7
In JPA transaction processing, if the operations execute successfully, you call EntityTransaction method _______ to commit the changes to the database. If any operation fails, you call EntityTransaction method ________ to return the database to its state prior to the transaction.

A) apply, rollback
B) commit, restore
C) apply, restore
D) commit, rollback
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following statements is false?

A) For certain types of projects, NetBeans automatically includes JPA support, but not for simple Java Application projects.
B) NetBeans projects do not include database drivers by default.
C) Each Java Enterprise Edition (Java EE) API-such as JPA-has a reference implementation that you can use to experiment with the API's features and implement applications.
D) The JPA reference implementation-which is included with the NetBeans Java EE version-is NetBeansLink.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
9
An object of type ________ is used to manage the data flow between the program and the database.

A) XE "Interfaces:EntityManager" XE "EntityManager interface" EntityManager
B) XE "Interfaces:EntityManagerFactory" XE "EntityManagerFactory interface" EntityManagerFactory XE "Classes:Persistence" XE "Persistence class"
C) Persistence
D) XE "Interfaces:TypedQuery" XE "TypedQuery interface" TypedQuery
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following JPA-related statements in false?

A) An object that implements the TypedQuery generic interface performs queries and returns a collection of matching entities.
B) To create queries, you can use EntityManager methods.
C) The Java Persistence Query Language (JPQL) is quite similar to SQL.
D) JPQL is optimized for dealing with relational database tables, rather than entity objects.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
11
For entity classes in JPA, an @NamedQueries annotation specifies a collection of ________ annotations that declare various named queries.

A) @Entity-Specifies that the class is an XE "entity class" entity class.
B) @Table-Specifies the entity class's corresponding database table.
C) @NamedQuery
D) None of the above.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
12
In JPA, when you compile the entity classes, the compiler looks at the annotations and adds JPA capabilities that help manage the interactions with the database-this is known as ________ capabilites.

A) implanting
B) injecting
C) infusing
D) instilling
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following statements about JPA database transaction processing is false?

A) Transaction processing enables a program that interacts with a database to treat a set of operations as a single operation. Such an operation also is known as an atomic operation or a transaction.
B) At the end of a transaction, a decision can be made either to commit the transaction or roll back the transaction.
C) Committing a transaction finalizes the database operation(s); all insertions, updates and deletions performed as part of the transaction cannot be reversed.
D) Rolling back the transaction leaves the database in its state prior to the database operation. This is useful when a portion of a transaction fails to complete properly.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
14
An object that implements the EntityManager ________ manages the interactions between a program and the database.

A) interface
B) class
C) enumeration
D) None of the above.
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
15
With JPA, as part of a persistence unit, the IDE also creates a ________ package in the Source Packages folder.

A) META-DATA
B) PERSISTENCE-INF
C) PU
D) META-INF
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
16
When you define a query in your own code, it's known as a(n) ________ query.

A) dynamic
B) static
C) active
D) passive
Unlock Deck
Unlock for access to all 16 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 16 flashcards in this deck.