1Z0-898 | High value Oracle 1Z0-898 exam question


Q21. Which two of the following statements are true of embeddable classes? (Choose two) 

A. An embeddable class must not be used to represent the state of another embeddable class. 

B. Null comparison operations over embeddable classes are not supported in the Java Persistence query language. 

C. An embeddable class must not contain a relationship to an entity. 

D. An embeddable class can be the key of a Map relationship. 

Answer: BD 

Q22. 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) 

A. Method doB will never be called. 

B. The current transaction will continue after doA executes. 

C. The current transaction will continue after doB executes. 

D. The current transaction will be marked for rollback when doA is called. 

E. The current transaction will be marked for rollback when doB is called. 

Answer: CE 

Q23. Given: 

Which statement is correct? 

A. The method will return TRUE. 

B. The method will return FALSE. 

C. The method will throw an exception. 

D. The order instance will be removed from the database. 

Answer:

Q24. Which one of the following queries selects the customer whose order has the highest total price? 

A. CriteriaBuilder cb = ... 

Criteria Query <Customer> cq = cb.create Query (Customer.class); 

Root<Customer> c = cq.from(Customer.class); 

Join<Customer, Order> o = c.join(Customer__.orders); 

cq.select(c).distinct(true); 

Subquery<Double> sq = cq.subquery(Double.class); 

Root<Order> subo = cq.correlate(o); 

sq.select(cb.max(subo.get(Order_.totalPrice))); 

cq.where(cb.equal(o.get(Order_.totalPrice), cb.all(sq))); 

B. CriteriaBuilder cb = ... 

CriteriaQuery<Customer> cq = cb.createquery(customer.class) 

Root<Customer> c = cq.from(Customer.class); 

Join<Customer, Order> o = c.join(Customer__.orders); 

cq.select(c).distinct(true); 

Subquery<Double> sq = cq.subquery(Double.class); 

Root<Order> subo = cq.correlate(o); 

sq.select(cb.max(subo.get(Order_.totalPrice))); 

cq.where(cb.equal(o.get(Order_.totalPrice), cb.all(sq))); 

C. CriteriaBuilder cb = ... 

CriteriaQuery<Customer> cq = cb.cteateQuery(Customer.class); 

Root<Customer> c = cq.from(Customer.class); 

Join<Customer, Order> o = c.join(Customer__.orders); 

cq.select(c).distinct(true); 

Subquery<Double> sq = cq.subquery(Double.class); 

Root<Order> subo = cq.correlate(o); 

sq.select(cb.max(subo.get(Order_.totalPrice))); 

cq.where(cb.equal(o.get(Order_.totalPrice), cb.all(sq))); 

D. CriteriaBuilder cb = ... 

CriteriaQuery<Customer> cq = cb.createQuery(Customer.class); 

Root<Customer> c = cq.from(Customer.class); 

Join<Customer, Order> o = c.join(Customer_.orders); 

cq.select(c).distinct(true); 

Subquery<Double> sq = cq.subquery(Double.class); 

Root<Order> subo = sq.from(Order.class); 

sq. select (ci: . max ( subo . get (Order_ . Total Price) ) ) ; 

cq.where(sq.all(o.gei(Order_.totalPrice))); 

Answer:

Q25. A developer has created an application managed entity manager. Which statement is correct? 

A. A new persistence context begins when the entity manager is created. 

B. A new persistence context begins when a new JTA transaction begins. 

C. A new persistence context begins when the entity manager is invoked in the context o transaction. 

D. A new persistence context begins when the entity manager is invoked in the context of a resource-local transaction. 

Answer:

Q26. Given a set of CMT bean methods with the following transaction attributes: 

Method M1 = SUPPORTS Method M2 = REQUIRED Method M3 = NOT_SUPPORTED 

Method M4 = REQUIRES_NEW 

And the following method invocation sequence: 

Method M1 invokes Method M2 

Method M2 invokes Method M3 

Method M1 invokes Method M4 

If Method M1 is invoked by a method that does NOT have a transaction context, which describes a possible scenario? 

A. Method M1 : no transaction Method M2 : new transaction Method M3 : no transaction Method M4 : new transaction 

B. Method M1 : no transaction Method M2 : Container throws TransactionNotSupportedException 

C. Method M1 : no transaction Method M2 : runs in same transaction as M1 Method M3 : container throws TransactionNotSupportException 

D. Method M1 : no transaction Method M2 : new transaction Method M3: Container throws TransactionNotSupportException. 

Answer:

Q27. An application uses an application-managed entity manager. Which of the following is NOT true? 

A. The application may specify whether the scope of the persistence context is extended. 

B. The application must use EntityManagerFactory instances to create entity managers. 

C. Entity manager instances must be explicitly closed. 

D. The application may need to call EntityManager. joinTransaction If a JTA aware entity manager is used. 

Answer:

Q28. Which of the following Criteria query snippets demonstrates the correct way to create and execute strongly typed queries? Assume that cb references an instance of the CriteriaBuilder interface and em references an EntityManager instance. 

A. CriteriaQuery <office> cq = cb.createQuery (Office.class); 

. . . 

TypedQuery<Office> tq = em.ceateQuery (cq) ; L 

1st <office> offices = tq.getResultList (); 

B. CriteriaQuery cq = cb.createQuery (Office.class) 

. . . 

TypedQuery<office> tq = em.createQuery (cq, office.class); 

List <office> offices = tq.getresult (); 

C. CriteriaQuery<office> cq = em.createQuery (cq, office.class); 

. . . 

TypedQuery<Office> tq = em.createQuery (cq); 

List <office> offices = tq.getresult (); 

D. CriteriaQuery <office> cq = cb.createQuery (Office.class); 

. . . 

TypedQuery<Office> tq = em.ceateQuery (cq); 

List<office> Offices = tq.getResultList (); 

Answer:

Q29. A developer is writing an application with three java Persistence API entities: order, customer, and Address. There is a many-to-one relationship between order and customer, and a one to-many relationship between customer and Address. 

Which two Criteria queries will return the orders of all customers who have an address whose value specified by the String parameter postalcode? (Choose two) 

A. String postalCode = . . . 

Criteria Builder cb = . . . 

CriteriaQuery<order> cq = cb.createQuery (Order.class); 

Root <order> order = cq.from(order.class); 

Join <order, Customer> customer = order.join(Order_.customer); 

Root <Order> order = cq.from (Order.class); 

Join <customer, Address> address = customer join (Order_.customer) 

cq.where (cb.equal (address.get(Address_.postalCode), postalCode)); 

cq.select (order). Distinct (true); 

// query execution code here 

. . . 

B. String postalCode = . . . 

Criteria Builder cb = . . . 

Root <Order> order = cq.from (Order.class); 

order.join (order_. customer).join(Customer_.addresses); 

cq.where (cb.equal (address.get(Address_.postalCode), postalCode)); 

cq.select (order). Distinct (true); 

// query execution code here 

C. String postalCode = ... 

CritetiaBuilder cb = ... 

Root<order> order = cq - from (Order . class) , 

Join<order, Address> address = order.join(Customer_.addresses); 

cq.where(ct>.equal(address.get(Address_.postalCode), postalCode)); 

cq-select(order).distinct(true); 

// query execution code here 

. . . 

D. String postalCode = ... 

CriteriaBuilder cb = ... 

Root<order> order = cq- from (Order . class ) , 

Join<order, Address> address = order . join (Order_. customer) -join (Customer_.addresses); 

cq.where <cb.equal (address.get(Address_.postalCode) , postalCode) ) ; 

cq.selec:(order).distinct(true); 

// query execution code here 

. . . 

Answer: CD 

Q30. The developer wants to define a unidirectional relationship from the customer entity to the order entity and map this relationship using a foreign key mapping strategy. 

Which one of the pairs of classes below correctly achieves this task? 

A. @Entity public class Customer { 

@Id int customerId; 

@OneToMany @JoinColumn (name = “CUST_ID”) Set <Order> orders; 

. . . 

@Entity public class order { 

@Id int orderId; 

. . . 

B. @Entity public class Customer { 

@Id int customerId; 

@OneToMany Set <Order> orders; 

. . . 

@Entity 

@JoinColumn (names = “CUST-ID”, referencedColumnName = “customerId”) 

public class order { 

@Id int order Id; 

. . . 

C. @Entity public class Customer { 

@Id int customerId; 

@OneToMany (JoinColumn = @joinColumn (name = “CUST_ID”) Set <Order> orders; 

. . . 

@Entity public class order { 

@Id int orderId; 

. . . 

D. @ Entity public class Customer { 

@Id int customerId; 

@OneToMany (JoinColumn = @JoinColumn (name = “CUST_ID”), table = “”ORDER) Set 

<Order> orders; 

. . . 

@Entity public class order { 

@Id int orderId; 

. . . 

Answer: