Click the Task button.
A Department entity is in a one-to-many relationship with an Employee entity. A developer has been asked to write a Java Persistence query to update the set of employees who are in the department 'HR' by setting their department to null.
Construct a query using the Java Persistence query language to perform this task. Construct a valid Java Persistence query by dragging and dropping the syntax fragements.
Select and Place:
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
A Reader entity has a one-to-many, bidirectional relationship with a Book entity. Two Reader entities are persisted, each having two Book entities associated with them. For example, readeM has booka and bookb, while reader2 has bookc and bookd. Which query returns a Collection of fewer than four elements?
A. SELECT b.reader FROM Book b
B. SELECT r FROM BookbINNER JOINb.readerr
C. SELECTrFROM Reader r INNER JOIN r.booksb
D. SELECTrfrom BookbLEFT JOIN b.readerr LEFTJOINFETCHr.books
A developer writes two session beans which cooperate. The first session bean, ShoppingCart, collects orders and is implemented as a stateful session bean. The second session bean, CalculateDiscount, is implemented as a stateless session bean and runs on a different server. ShoppingCart contains the method getTotalPrice, which calculates the total price of the order in the ShoppingCart, including discounts. Discounts are calculated by CalculateDiscount using the information on the ShoppingCart bean, combined with data from a database. Which scenario can accomplish this?
A. The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean passing the this reference.
B. The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean. CalculateDiscount accesses the ShoppingCart instance by JNDI lookup.
C. The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean passing its reference obtained from the SessionContext.getBusinessObject method.
D. The CalculateDiscount offers a method calculate which is invoked by the ShoppingCart bean. CalculateDiscount accesses the state of ShoppingCart by dependency injection.
The Java Persistent API defines certain rules for persistent entities. These rules are required by the persistent provider to manage entities at runtime. Which statement is correct, assuming NO mapping descriptor is used?
A. Entitiesmust extenda persistent base class.
B. Entities must implement the interface PersistentEntityto bemanaged bythepersistent provider.
C. Afield withoutatransient modifier mustbeannotated as ©Persistent tobe stored in the database.
D. A field without a transient modifier must be annotated as ©Transient to NOT be stored in the database.
A developer is creating a long-running Java Persistence reporting application that accesses a set of related entities. The application is NOT expected to add, change, or remove records in the database but the data can be changed by another application running on the same database. Which option will guarantee that the report does NOT contain stale data?
A. CalltheEntityManagerflush API before preparing the report.
B. CalltheEntityManager createOueryAPIbeforepreparingthe report.
C. Call the EntityManager clearAPIbefore accessing thefieldsor properties of the entities used in the report.
D. CalltheEntityManager refresh on each parent entity that is added to the report, and specify cascade=REFRESH onallcorresponding relationships.
A developer wants to create a portable EJB 3.0 application that includes the following class definition for the Entity Account: 11.©Entity
12.
@Entityl_isteners(com. acme.AlertMonitor. class)
13.
public class Account {
14.
// more code here
15.
@PrePersist
16.
protected void validateCreate0 {/* more code here */} 17.} Which statement is correct?
A. The validateCreate method may NOT throwruntimeexceptions.
B. ThevalidateCreate method can invoke the EntityManager.flush operation.
C. Methods oftheclass com.acme.AlertMonitor annotatedwithcallback annotationsmusttake an Object or Account instance astheonly argument.
D. The above class definition is NOT correct. An entity cannot defineacallback methodlike PrePersistand use the EntityListeners annotationatthe same time.
Which statement is true about the Timer service in an EJB 3.0 stateless session bean?
A. The timeout callback method contains the business logic that handles the timeout event.
B. The timeout callback method must be declared as a business method in business interfaces.
C. The timeout callback method can throw application exceptions to report business logic failures.
D. A bean class can implement multiple timeout callback methods, each associated with a different timer.
Consider the following classes: 11.©Entity Auction {
12.
@ld int id;
13.
@OneToOne Item item;
14.}
11.©Entity Itemj
12.
@ld int id;
13.
@OneToOne (mappedBy="item") Auction auction;
14.
}
Given that the Auction entity maps to an AUCTION database table and the Item entity maps to an ITEM database table, which statement is correct assuming there is NO mapping descriptor?
A. The relationship is mapped to a foreign key in the ITEMtable.
B. Therelationship is mapped usingajointableAUCTIONJTEM.
C. The relationship is mappedtoaforeignkeyinthe AUCTIONtable.
D. The relationshipis mapped to foreignkeysinbothITEMandAUCTION tables.
Given:
A stateless session bean's business method invokes EJBContext.setRollbackOnly and receives an Illegal StateExe option. Under which of these conditions could this be possible?
A. The business method is marked with the MANDATORY transaction attribute.
B. The business method is marked with the NONSUPPORTED transaction attribute.
C. This is NOT possible; a stateless session bean cannot invoke EJBContext.setRollbackOnly.
D. The bean has no metadata (in annotations or deployment descriptor) which specifies the transaction attribute for the method.