Search your topic in Java2share
Home > SCBCD > SCBCD Question Bank
eXTReMe Tracker


8. Java Persistence Query Language (SCBCD)

Q: 01 Which two options can be used to predefine Java Persistence queries for easy
use? (Choose two.)

A. @NamedQuery annotation
B. @NamedNativeQuery annotation
C. using the named-query element in the XML descriptor
D. using the named-native-query element in the XML descriptor

Answer: A, C

 

Q: 02 A developer wants to create a Java Persistence query that returns valid U.S.
phone numbers (formatted as "123-456-7890" or "800-RUN-EJB3") from a collection of differently
formatted international phone numbers. The developer needs only those numbers that begin with 303.
Which WHERE clause is correct?

A. WHERE addr.phone LIKE '303_'
B. WHERE addr.phone LIKE '303%'
C. WHERE addr.phone LIKE '303-_-_'
D. WHERE addr.phone LIKE '303-%-%'
E. WHERE addr.phone LIKE '303-___-____'
F. WHERE addr.phone LIKE '303-%%%-%%%%'

Answer: E

 

Q: 03 Which Java Persistence query uses the aggregate function correctly, assuming
that chairs field is of type int?

A. SELECT ANY(r.chairs) FROM Room r
B. SELECT NEW Integer(MAX(r.chairs)) FROM Room r
C. SELECT r FROM Room r WHERE r.chairs > AVG(r.chairs)
D. SELECT c FROM Chair c WHERE LOCATE (c.type, 'lazyboy') > -1

Answer: B

Q: 04 A business method of a stateless session bean with a transaction attribute
REQUIRED executes a Java Persistence query on a container-managed persistence context.
Under which two conditions can the developer expect the persistence provider to ensure that all changes
made to the persistence context in the transaction are visible to the processing of the query? (Choose
two.)

A. The flush mode is NOT explicitly set.
B. The flush mode on the Query object is set to COMMIT.
C. The refresh method on the EntityManager is called.
D. The flush mode on the persistence context is set to AUTO but is NOT specified for the Query object.

Answer: A, D