Oracle 1z0-898 Exam Practice Questions (P. 1)
- 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 #1
Entity lifecycle callback methods may be defined in which three classes? (Choose three)
- AEmbedded classes
- BEntity classes
- CAbstract classes
- DEntity listener classes
- EMapped superclasses
- FConcrete non-entity superclasses
Correct Answer:
BDE
Entity Listeners and Callback Methods
A method may be designated as a lifecycle callback method to receive notification of entity lifecycle events. A lifecycle callback method can be defined on an entity class, a mapped superclass, or an entity listener class associated with an entity or mapped superclass.
Reference: How to inject a spring's service bean into a JPA Entity?
http://stackoverflow.com/questions/3747268/how-to-inject-a-springs-service-bean-into-a-jpa-entity
BDE
Entity Listeners and Callback Methods
A method may be designated as a lifecycle callback method to receive notification of entity lifecycle events. A lifecycle callback method can be defined on an entity class, a mapped superclass, or an entity listener class associated with an entity or mapped superclass.
Reference: How to inject a spring's service bean into a JPA Entity?
http://stackoverflow.com/questions/3747268/how-to-inject-a-springs-service-bean-into-a-jpa-entity
send
light_mode
delete
Question #2
A developer wrote an entity class with the following method:
Private static Logger logger = Logger.getLogger ("myLogger");
@PrePersist
@PreUpdate
Public void doA () {
Logger.info ("A");
}
@PostPersist
@PostUpdate
Public void doB () {
logger.info ("B");
}
What will the log message contain when an application does the following?
1. Begins a transaction
2. Creates the entity
3. Persists the entity
4. Commits the transaction
5. Begins the entity data
6. Modifies the entity data
7. Merges the entity
8. Commits the second transaction
Private static Logger logger = Logger.getLogger ("myLogger");
@PrePersist
@PreUpdate
Public void doA () {
Logger.info ("A");
}
@PostPersist
@PostUpdate
Public void doB () {
logger.info ("B");
}
What will the log message contain when an application does the following?
1. Begins a transaction
2. Creates the entity
3. Persists the entity
4. Commits the transaction
5. Begins the entity data
6. Modifies the entity data
7. Merges the entity
8. Commits the second transaction
- AA A B B
- BA B A B
- CA B B A B
- DThe application will throw an exception because multiple lifecycle callback annotations applied to a single method.
Correct Answer:
B
B
send
light_mode
delete
Question #3
Given the following code:
Public void create () {
try {
doA () {
} catch (PersistenceException e) {}
try (doB) ();
} catch (PersistenceException e) {}
}
Calling method doA will cause an NonUniqueResultException to be thrown. Calling method doB will cause an EntityExistsException to be thrown.
What two options describe what will happen when the create method is called within an application ' uses container managed transactions? (Choose two)
Public void create () {
try {
doA () {
} catch (PersistenceException e) {}
try (doB) ();
} catch (PersistenceException e) {}
}
Calling method doA will cause an NonUniqueResultException to be thrown. Calling method doB will cause an EntityExistsException to be thrown.
What two options describe what will happen when the create method is called within an application ' uses container managed transactions? (Choose two)
- AMethod doB will never be called.
- BThe current transaction will continue after doA executes.
- CThe current transaction will continue after doB executes.
- DThe current transaction will be marked for rollback when doA is called.
- EThe current transaction will be marked for rollback when doB is called.
Correct Answer:
BE
B:
PersistenceException is thrown by the persistence provider when a problem occurs. All instances of PersistenceException except for instances of
NoResultException, NonUniqueResultException, LockTimeoutException, and QueryTimeoutException will cause the current transaction, if one is active, to be marked for rollback.
E: EntityExistsException is thrown by the persistence provider when EntityManager.persist(Object) is called and the entity already exists. The current transaction, if one is active, will be marked for rollback.
Reference: javax.persistence, Class PersistenceException
Reference: javax.persistence, Class EntityExistsException
BE
B:
PersistenceException is thrown by the persistence provider when a problem occurs. All instances of PersistenceException except for instances of
NoResultException, NonUniqueResultException, LockTimeoutException, and QueryTimeoutException will cause the current transaction, if one is active, to be marked for rollback.
E: EntityExistsException is thrown by the persistence provider when EntityManager.persist(Object) is called and the entity already exists. The current transaction, if one is active, will be marked for rollback.
Reference: javax.persistence, Class PersistenceException
Reference: javax.persistence, Class EntityExistsException
send
light_mode
delete
Question #4
An application that uses pessimistic locking calls an updateData method that results in a LockTimeoutException being thrown. What three statements are correct?
(Choose three)
(Choose three)
- AThe current transaction continues.
- BThe current statement continues.
- CThe current transaction is rolled back.
- DThe current statement is rolled back.
- EThe LockTimeoutException can NOT be caught.
- FThe LockTimeoutException can be caught, and the updateData method retried.
Correct Answer:
ADF
LockTimeoutException is thrown by the persistence provider when an pessimistic locking conflict occurs that does not result in transaction rollback. This exception may be thrown as part of an API call, at, flush or at commit time. The current transaction, if one is active, will be not be marked for rollback.
Reference: javax.persistence, Class LockTimeoutException
ADF
LockTimeoutException is thrown by the persistence provider when an pessimistic locking conflict occurs that does not result in transaction rollback. This exception may be thrown as part of an API call, at, flush or at commit time. The current transaction, if one is active, will be not be marked for rollback.
Reference: javax.persistence, Class LockTimeoutException
send
light_mode
delete
Question #5
A developer has created a deep entity class hierarchy with many polymorphic relationships between entitles. Which inheritance strategy, as defined by the inheritanceType enumerated type, will be most performed in this scenario?
- ASingle table-per-class-hierarchy (InheritanceType.SINGLE_TABLE)
- BJoined-subclass (inheritanceType. JOINED)
- CTable-per-concrete-class (inheritanceType.TABLE_PER_CLASS)
- DPolymorphic join table (inheritanceType. POLYMORPHIC_JOIN_TABLE)
Correct Answer:
A
The Single Table per Class Hierarchy Strategy
This strategy provides good support for polymorphic relationships between entities and queries that cover the entire entity class hierarchy.
Note: Enum InheritanceType:
* SINGLE_TABLE
A single table per class hierarchy.
* JOINED
A strategy in which fields that are specific to a subclass are mapped to a separate table than the fields that are common to the parent class, and a join is performed to instantiate the subclass.
* TABLE_PER_CLASS
A table per concrete entity class.
Incorrect:
Not D: There is no such thing as inheritanceType.POLYMORPHIC_JOIN_TABLE.
Reference: Entity Inheritance Mapping Strategies
javax.persistence, Enum InheritanceType
A
The Single Table per Class Hierarchy Strategy
This strategy provides good support for polymorphic relationships between entities and queries that cover the entire entity class hierarchy.
Note: Enum InheritanceType:
* SINGLE_TABLE
A single table per class hierarchy.
* JOINED
A strategy in which fields that are specific to a subclass are mapped to a separate table than the fields that are common to the parent class, and a join is performed to instantiate the subclass.
* TABLE_PER_CLASS
A table per concrete entity class.
Incorrect:
Not D: There is no such thing as inheritanceType.POLYMORPHIC_JOIN_TABLE.
Reference: Entity Inheritance Mapping Strategies
javax.persistence, Enum InheritanceType
send
light_mode
delete
All Pages