Oracle 1z0-898 Exam Practice Questions (P. 3)
- Full Access (63 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #11
If an application uses an extended persistence context, which of the following is true?
- AThe persistence context exists until all transactions invoked by the EntityManager complete.
- BThe persistence context exists until all transactions invoked by the EntityManagar complete and the EntityManager.clear () method is invoked.
- CThe persistence context exists until the EntityManager instance is closed.
- DThe persistence context exists until the EntityManagerFactory instance is closed.
Correct Answer:
C
The extended persistence context exists from the point at which the entity manager has been created using EntityManagerFactory.createEntityManager until the entity manager is closed by means of EntityManager.close.
Reference: Identify correct and incorrect statements or examples about application-managed persistence contexts.
http://java.boot.by/scbcd5-guide/ch07s03.html
C
The extended persistence context exists from the point at which the entity manager has been created using EntityManagerFactory.createEntityManager until the entity manager is closed by means of EntityManager.close.
Reference: Identify correct and incorrect statements or examples about application-managed persistence contexts.
http://java.boot.by/scbcd5-guide/ch07s03.html
send
light_mode
delete
Question #12
An application uses an application-managed entity manager. Which of the following is NOT true?
- AThe application may specify whether the scope of the persistence context is extended.
- BThe application must use EntityManagerFactory instances to create entity managers.
- CEntity manager instances must be explicitly closed.
- DThe application may need to call EntityManager. joinTransaction if a JTA aware entity manager is used.
Correct Answer:
D
When a JTA application-managed entity manager is used, if the entity manager is created outside the scope of the current JTA transaction, it is the responsibility of the application to associate the entity manager with the transaction (if desired) by calling EntityManager.joinTransaction.
Reference: Identify correct and incorrect statements or examples about application-managed persistence contexts.
http://java.boot.by/scbcd5-guide/ch07s03.html
D
When a JTA application-managed entity manager is used, if the entity manager is created outside the scope of the current JTA transaction, it is the responsibility of the application to associate the entity manager with the transaction (if desired) by calling EntityManager.joinTransaction.
Reference: Identify correct and incorrect statements or examples about application-managed persistence contexts.
http://java.boot.by/scbcd5-guide/ch07s03.html
send
light_mode
delete
Question #13
An application that uses container-managed transaction demarcation creates a query within an active transaction and receives a QueryTimeoutException. Which of those scenarios describes what happens to the active transaction?
- AThe statement and the transaction continue.
- BThe query is recreated within the current transaction.
- CThe statement and the transaction are marked for rollback.
- DThe statement is rolled back, but the transaction continues.
Correct Answer:
D
QueryTimeoutException is thrown by the persistence provider when a query times out and only the statement is rolled back. The current transaction, if one is active, will be not be marked for rollback.
Reference: javax.persistence, Class QueryTimeoutException
http://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/QueryTimeoutException.html
D
QueryTimeoutException is thrown by the persistence provider when a query times out and only the statement is rolled back. The current transaction, if one is active, will be not be marked for rollback.
Reference: javax.persistence, Class QueryTimeoutException
http://docs.jboss.org/hibernate/jpa/2.1/api/javax/persistence/QueryTimeoutException.html
send
light_mode
delete
Question #14
The developer has defined the following entity class office:
@Entity
public class Office {
@Id
private int id;
private String name;
@OneToMany
private List<Room> rooms;
}
Which of the following attributes will be in corresponding generated static metamodel class for the rooms field?
@Entity
public class Office {
@Id
private int id;
private String name;
@OneToMany
private List<Room> rooms;
}
Which of the following attributes will be in corresponding generated static metamodel class for the rooms field?
- APublic static volatile CollectionAttribute<Room> rooms;
- BPublic static volatile ListAttribute<Room> rooms;
- CPublic static volatile ListAttribute<Office, Room> rooms;
- DPublic static volatile SingleAttribute<Room> rooms;
Correct Answer:
C
* Annotation Type OneToMany
Defines a many-valued association with one-to-many multiplicity.
* Interface ListAttribute<X,E>
Type Parameters:
X - The type the represented List belongs to
E - The element type of the represented List
Incorrect:
not A: A collection cannot reprecent a one to many relationship.
Reference: javax.persistence, Annotation Type OneToMany
C
* Annotation Type OneToMany
Defines a many-valued association with one-to-many multiplicity.
* Interface ListAttribute<X,E>
Type Parameters:
X - The type the represented List belongs to
E - The element type of the represented List
Incorrect:
not A: A collection cannot reprecent a one to many relationship.
Reference: javax.persistence, Annotation Type OneToMany
send
light_mode
delete
Question #15
Given two entities with many-to-many bidirectional association between them:
@Entity public class Employee {
Collection projects;
// more code here
}
and
@Entity public class Project {
Set<Employee> emps;
// more code here
}
What set of annotations correctly defines the association?
@Entity public class Employee {
Collection projects;
// more code here
}
and
@Entity public class Project {
Set<Employee> emps;
// more code here
}
What set of annotations correctly defines the association?
- A@manyToMany on the projects field, @manyToMany (mappedBy= "projects") on the emps field
- B@manyToMany (mappedBy = emps) on the projects field, @manyToMany on the emps field
- C@manyToMany (targetEntity = project.class) on the projects field, @manyToMany (mappedBy = "projects") on the emps field
- D@manyToMany (targetEntity = project.class) on the projects field,
Correct Answer:
C
Every many to many relationship has obviously two sides: a Owning side and the Inverse side (which is... non-owning).
Here the Employee class is the owning side.
targetEntity: The entity class that is the target of the association. The dot (".") notation syntax must be used in the mappedBy element to indicate the relationship attribute within the embedded attribute.
This mappedBy element is mandatory and must be placed on the Inverse side of the relationship in case we are mapping a Bidirectional. Here Projects class is on the inverse side.
Note: @manyToMany defines a many-valued association with many-to-many multiplicity.
Every many-to-many association has two sides, the owning side and the non-owning, or inverse, side. The join table is specified on the owning side. If the association is bidirectional, either side may be designated as the owning side. If the relationship is bidirectional, the non-owning side must use the mappedBy element of the ManyToMany annotation to specify the relationship field or property of the owning side.
Reference: javax.persistence, Annotation Type ManyToMany
JPA 2 Tutorial Relationships Many To Many
C
Every many to many relationship has obviously two sides: a Owning side and the Inverse side (which is... non-owning).
Here the Employee class is the owning side.
targetEntity: The entity class that is the target of the association. The dot (".") notation syntax must be used in the mappedBy element to indicate the relationship attribute within the embedded attribute.
This mappedBy element is mandatory and must be placed on the Inverse side of the relationship in case we are mapping a Bidirectional. Here Projects class is on the inverse side.
Note: @manyToMany defines a many-valued association with many-to-many multiplicity.
Every many-to-many association has two sides, the owning side and the non-owning, or inverse, side. The join table is specified on the owning side. If the association is bidirectional, either side may be designated as the owning side. If the relationship is bidirectional, the non-owning side must use the mappedBy element of the ManyToMany annotation to specify the relationship field or property of the owning side.
Reference: javax.persistence, Annotation Type ManyToMany
JPA 2 Tutorial Relationships Many To Many
send
light_mode
delete
All Pages