Download Java EE 6 Java Persistence API Developer Certified Expert.1z0-898.PracticeDumps.2018-01-04.63q.vcex

Vendor: Oracle
Exam Code: 1z0-898
Exam Name: Java EE 6 Java Persistence API Developer Certified Expert
Date: Jan 04, 2018
File Size: 1 MB

How to open VCEX files?

Files with VCEX extension can be opened by ProfExam Simulator.

Demo Questions

Question 1
Entity lifecycle callback methods may be defined in which three classes? (Choose three)
  1. Embedded classes
  2. Entity classes
  3. Abstract classes
  4. Entity listener classes
  5. Mapped superclasses
  6. Concrete non-entity superclasses
Correct answer: BDE
Explanation:
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
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
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
  1. B
  2. B
  3. B
  4. The application will throw an exception because multiple lifecycle callback annotations applied to a single method.
Correct answer: B
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)
  1. Method doB will never be called.
  2. The current transaction will continue after doA executes.
  3. The current transaction will continue after doB executes.
  4. The current transaction will be marked for rollback when doA is called.
  5. The current transaction will be marked for rollback when doB is called.
Correct answer: BE
Explanation:
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 PersistenceExceptionReference: javax.persistence, Class EntityExistsException
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
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)
  1. The current transaction continues.
  2. The current statement continues.
  3. The current transaction is rolled back.
  4. The current statement is rolled back.
  5. The LockTimeoutException can NOT be caught.
  6. The LockTimeoutException can be caught, and the updateData method retried.
Correct answer: ADF
Explanation:
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
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
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?
  1. Single table-per-class-hierarchy (InheritanceType.SINGLE_TABLE)
  2. Joined-subclass (inheritanceType. JOINED)
  3. Table-per-concrete-class (inheritanceType.TABLE_PER_CLASS)
  4. Polymorphic join table (inheritanceType. POLYMORPHIC_JOIN_TABLE)
Correct answer: A
Explanation:
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 Strategiesjavax.persistence, Enum InheritanceType
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
Question 6
A developer is creating an entity which is mapped to a table that has a primary key constraint defined on two character columns and would like to use mapping defaults as much as possible to simplify the code. 
Which two mapping options can be chosen? (Choose two.)
  1. Use an @id property that constructs a private field as a concatenation of two columns.
  2. Use a separate class to map those two columns and use an @idclass annotation to denote I primary key field or property in the entity.
  3. Use a separate @Embeddable class to map those two columns and use an @EmbeddedId annotation to denote a single primary key field or property in the entity.
  4. Use a separate @Embeddable class to map those two column and add two fields or properties the entity, each marked as @id, that correspond to the fields or properties in the embeddable class.
  5. Use a separate class to map those two columns. Specify that class using @Idclass annotation on the entity class. Add two fields or properties to the entity, each marked as @Id, that correspond to the fields or properties in that separate class.
Correct answer: CE
Explanation:
C: Annotation Type EmbeddedIdApplied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. The embeddable class must be annotated as Embeddable. E: Annotation Type IdClassSpecifies a composite primary key class that is mapped to multiple fields or properties of the entity. The names of the fields or properties in the primary key class and the primary key fields or properties of the entity must correspond and their types must be the same. Example: @IdClass(com.acme.EmployeePK.class)    @Entity    public class Employee {      @Id String empName;      @Id Date birthDay;      ...    } Reference: javax.persistence, Annotation Type EmbeddedIdjavax.persistence , Annotation Type IdClass
C: Annotation Type EmbeddedId
Applied to a persistent field or property of an entity class or mapped superclass to denote a composite primary key that is an embeddable class. The embeddable class must be annotated as Embeddable. 
E: Annotation Type IdClass
Specifies a composite primary key class that is mapped to multiple fields or properties of the entity. The names of the fields or properties in the primary key class and the primary key fields or properties of the entity must correspond and their types must be the same. 
Example: 
@IdClass(com.acme.EmployeePK.class) 
   @Entity 
   public class Employee { 
     @Id String empName; 
     @Id Date birthDay; 
     ... 
   } 
Reference: javax.persistence, Annotation Type EmbeddedId
javax.persistence , Annotation Type IdClass
Question 7
A developer wants to model the grades for a student as a Map<course, integer>. Assume that Student and Course are entitles, and that grades are modeled by integers. 
Which of the following two statements are correct? (Choose two)
  1. The developer can model the grades as an element collection in the Student entity.
  2. The developer can model the grades as a oneToMany relationship in the Student entity.
  3. The mapping for the key of the map can be specified by the @MapKeycolumn annotation.
  4. The mapping for the value of the map can be specified by the @Column annotation.
Correct answer: AD
Explanation:
A: JPA 2.0 defines an ElementCollection mapping. It is meant to handle several non-standard relationship mappings. An ElementCollection can be used to define a one-to-many relationship to an Embeddable object, or a Basic value (such as a collection of Strings). An ElementCollection can also be used in combination with a Map to define relationships where the key can be any type of object, and the value is an Embeddable object or a Basic value.D: Example of an ElementCollection relationship database:    Example of an ElementCollection relationship annotations @Entity public class Employee {   @Id   @Column(name="EMP_ID")   private long id;   ...   @ElementCollection   @CollectionTable(         name="PHONE",         joinColumns=@JoinColumn(name="OWNER_ID")   )   private List<Phone> phones;   ... } @Embeddable public class Phone {   private String type;   private String areaCode;   @Column(name="P_NUMBER")   private String number;   ... } Reference: Java Persistence/ElementCollection
A: JPA 2.0 defines an ElementCollection mapping. It is meant to handle several non-standard relationship mappings. An ElementCollection can be used to define a one-to-many relationship to an Embeddable object, or a Basic value (such as a collection of Strings). An ElementCollection can also be used in combination with a Map to define relationships where the key can be any type of object, and the value is an Embeddable object or a Basic value.
D: 
Example of an ElementCollection relationship database: 
   
Example of an ElementCollection relationship annotations 
@Entity 
public class Employee { 
  @Id 
  @Column(name="EMP_ID") 
  private long id; 
  ... 
  @ElementCollection 
  @CollectionTable( 
        name="PHONE", 
        joinColumns=@JoinColumn(name="OWNER_ID") 
  ) 
  private List<Phone> phones; 
  ... 
@Embeddable 
public class Phone { 
  private String type; 
  private String areaCode; 
  @Column(name="P_NUMBER") 
  private String number; 
  ... 
Reference: Java Persistence/ElementCollection
Question 8
Consider a persistence application with the following orm.xml:
   
What will be the effect of the above orm.xml?
  1. The access type for only those entities that have not explicitly specified @Access will be defaulted to field.
  2. The access type for all entities in the persistence unit will be changed to FIELD.
  3. The access type for all entities specified in this orm.xml will be changed to FIELD.
  4. The access type for only those entities defined in this orm.xml for which access is not specified will be defaulted to FIELD.
Correct answer: D
Explanation:
Set the default to FIELD-access. Note: persistence-unit-defaultsRule: Full overrideDescription: If a schema setting exists, then the eclipselink-orm.xml schema setting overrides the existing setting or creates a new schema setting.
Set the default to FIELD-access. 
Note: persistence-unit-defaults
Rule: Full override
Description: If a schema setting exists, then the eclipselink-orm.xml schema setting overrides the existing setting or creates a new schema setting.
Question 9
A developer has created an application managed entity manager. 
Which statement is correct?
  1. A new persistence context begins when the entity manager is created.
  2. A new persistence context begins when a new JTA transaction begins.
  3. A new persistence context begins when the entity manager is invoked in the context o\ transaction.
  4. A new persistence context begins when the entity manager is invoked in the context of a resource-local transaction.
Correct answer: A
Explanation:
Application-Managed Entity Managers With an application-managed entity manager the persistence context is not propagated to application components, and the lifecycle of EntityManager instances is managed by the application. Application-managed entity managers are used when applications need to access a persistence context that is not propagated with the JTA transaction across EntityManager instances in a particular persistence unit. In this case, each EntityManager creates a new, isolated persistence context. The EntityManager and its associated persistence context are created and destroyed explicitly by the application. Reference: The Java EE 6 Tutorial, Managing Entitieshttp://docs.oracle.com/javaee/6/tutorial/doc/bnbqw.html#bnbra
Application-Managed Entity Managers 
With an application-managed entity manager the persistence context is not propagated to application components, and the lifecycle of EntityManager instances is managed by the application. 
Application-managed entity managers are used when applications need to access a persistence context that is not propagated with the JTA transaction across EntityManager instances in a particular persistence unit. In this case, each EntityManager creates a new, isolated persistence context. The EntityManager and its associated persistence context are created and destroyed explicitly by the application. 
Reference: The Java EE 6 Tutorial, Managing Entities
http://docs.oracle.com/javaee/6/tutorial/doc/bnbqw.html#bnbra
Question 10
Given:
      @PersistenceContext EntityManager em; 
       public boolean test(Order o) { 
           boolean b = false; 
           o = em.merge(o); 
           em.remove(o); 
           o = em.merge(o); 
           b = em.contains(o); 
           return b; 
       } 
Which statement is correct?
  1. The method will return TRUE.
  2. The method will return FALSE.
  3. The method will throw an exception.
  4. The order instance will be removed from the database.
Correct answer: A
Explanation:
* Order An object that defines an ordering over the query results. * merge(T entity)            Merge the state of the given entity into the current persistence context * remove(java.lang.Object entity)            Remove the entity instance. * contains(java.lang.Object entity)            Check if the instance is a managed entity instance belonging to the current persistence context. Note: An EntityManager instance is associated with a persistence context. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their lifecycle are managed. The EntityManager API is used to create and remove persistent entity instances, to find entities by their primary key, and to query over entities.The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit. A persistence unit defines the set of all classes that are related or grouped by the application, and which must be colocated in their mapping to a single database
* Order 
An object that defines an ordering over the query results. 
* merge(T entity)  
          Merge the state of the given entity into the current persistence context 
* remove(java.lang.Object entity)  
          Remove the entity instance. 
* contains(java.lang.Object entity)  
          Check if the instance is a managed entity instance belonging to the current persistence context. 
Note: An EntityManager instance is associated with a persistence context. A persistence context is a set of entity instances in which for any persistent entity identity there is a unique entity instance. Within the persistence context, the entity instances and their lifecycle are managed. The EntityManager API is used to create and remove persistent entity instances, to find entities by their primary key, and to query over entities.
The set of entities that can be managed by a given EntityManager instance is defined by a persistence unit. A persistence unit defines the set of all classes that are related or grouped by the application, and which must be colocated in their mapping to a single database
HOW TO OPEN VCE FILES

Use VCE Exam Simulator to open VCE files
Avanaset

HOW TO OPEN VCEX FILES

Use ProfExam Simulator to open VCEX files
ProfExam Screen

ProfExam
ProfExam at a 20% markdown

You have the opportunity to purchase ProfExam at a 20% reduced price

Get Now!