A User entity is in a one-to-many relationship with a Book entity. Assume that a developer has a function fetchBook(String title) that fetches a Book entity with the given title title. Also assume that the developer has an entity manager em. Which query can be used to return the user that holds the book titled "Java"?
-
A
em.createQueryfSELECT u FROM User u where :great IN
-
B
books.title").setParameter("great","Java")
-
C
em.createQuery("SELECT u FROM User u where :great IN
-
D
books"). setParameter("great",fetchBook("Java"))
-
E
em.createQuery("SELECT u FROM User u where :great MEMBER OF
-
F
books.title"). setParameter("great" ."Java")
-
G
em.createQuery("SELECT u FROM User u where :great MEMBER OF
-
H
books"). setParameter("great",fetchBook("Java"))
Reveal answer details
Close answer details
Question 2
Multiple choice
A developer implements a session bean which acts as a session facade for an application. This means that clients will only see this session bean's interface which offers the application interface. There are three distinct roles known at development time"user", "admin", and "guest". The majority of the methods will be used by role "user". All methods must have role permissions active and roles may be added or changed in the future. Which two scenarios are correct? (Choose two.)
-
A
The developer annotates the bean class with @PermitAII and annotates the methods used by role"guest" or "admin" individually.
-
B
The developer annotates the bean class with @DenyAII and annotates the methods used by role"user", "guest", or "admin" individually.
-
C
The developer defines individual method permissions for the methods used by roles "user","guest", and "admin" in the deployment descriptor.
-
D
The developer annotates the bean class with @RolesAllowed("user") and annotates the methods used by role "guest" or "admin" individually.
-
E
Thedeveloper defines a method permission with method name "*" and role "user" and adds individual method permissions for the methods used by roles "guest" and "admin" in the deployment descriptor.
Reveal answer details
Close answer details
A developer implements a system in which transfers of goods are monitored. Each transfer needs a unique ID for tracking purposes. The unique ID is generated by an existing system which is also used by other applications. For perfomance reasons, the transaction that gets the unique ID should be as short as possible. The scenario is implemented in four steps which are implemented in four business methods in a CMT session bean: LcheckGoods Checks goods in a database 2. getUniqueld Retrieve the unique ID 3. checkAmount Checks the amount in a non-transactional system 4. storeTransfer Stores the transfer in a database as part of the calling transaction. These methods are called by the addTransfer method of a second CMT session bean in the following order: checkGoods, getUniqueld, checkAmount, storeTransfer Assuming no other transaction-related metadata, which is the correct set of transaction attributes for the methods in the session beans?
-
A
0. addTransfer REQUIRED 1. LcheckGoods REQUIRED 2. getUniqueldREQUIRES_NEW 3. checkAmountsNOT_SUPPORTED 4. storeTransferMANDATOR Y
-
B
0. addTransferREQUIRED 1. LcheckGoods REQUIRED 2. getUniqueldREQUIRED 3. checkAmountsREQUIRED 4. storeTransferREQUIRED
-
C
0. addTransferREQUIRED 1. LcheckGoods REQUIRED 2. getUniqueldREQUIRES_NEW 3. checkAmountsNEVER 4. storeTransferMANDATOR Y
-
D
0. addTransferNOT_SUPPORTED 1. LcheckGoodsREQUIRED 2. getUniqueldREQUIRED 3. checkAmountsNOT_SUPPORTED 4. storeTransferMANDATOR Y
Reveal answer details
Close answer details
Which method always throws an exception when invoked on a container-managed entity manager?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Which statement about entity manager is true?
-
A
A container-managed entity manager must be a JTA entity manager.
-
B
An entity manager injected into session beans can use either JTA or resource-local transaction control.
-
C
An entity manager created by calling the EntityManagerFactory.createEntityManager method always uses JTA transaction control.
-
D
An entity manager obtained through resource injection in a stateful session bean can use a resource-local EntityTransaction for transaction control
Reveal answer details
Close answer details
Which is the correct way of declaring bean-managed transaction demarcation for an EJB 3.0 message-driven bean?
-
A
@MessageDriven public class MyMessageBean implements MessageListener, UserTransaction {
-
B
@MessageDriven @TransactionManagement(TransactionManagementType.BEAN) public class MyMessageBean implements MessageListener { C. @MessageDriven public class MyMessageBean implements MessageListener) @TransactionManagement (TransactionManagementType.BEAN) public void onMessage(Message message) {...}
-
C
@MessageDriven (transactionManagement=TransactionManagementType.BEAN) public class MyMessageBean implements MessageListener {
Reveal answer details
Close answer details
Which option will a developer use to obtain a MessageDrivenContext in a message-driven bean class written to the EJB 3.0 API?
-
A
Implement the MessageDrivenBean interface.
-
B
Specify MessageDrivenContext as a constructor parameter.
-
C
Declare a dependency on the MessageDrivenContext interface.
-
D
Specify MessageDrivenContext as a parameter of the onMessage method.
Reveal answer details
Close answer details
Which is the valid use of the javax.ejb.lnit annotation?
-
A
to annotate a method in a stateful session bean class so that the container will invoke it after the EJB is deployed and started
-
B
to specify the correspondence of a method on a stateful session bean class with a create method of the adapted home interfaces
-
C
to annotate a bean class inside the ejb-jar archive to act as a bootstrap EJB which is loaded into the container before any other EJBs
-
D
for a client to invoke the method annotated with @lnit to initialize a newly created stateful session bean instance with user-specific data
Reveal answer details
Close answer details
An enterprise developer has received ejb-jars from multiple Bean Providers and wants to combine them into a single ejb-jar as well as altering the method permissions on some of the beans without recompiling any of the code contained in the ejb-jar. Which is correct?
-
A
Bean Provider is the only role that can perform this task.
-
B
Deployeris the most appropriaterole toperform thistask.
-
C
EitheraDeployer or System Administrator role may perform this task.
-
D
This problem cannot be solved using an EJB 3.0-compliant approach.
-
E
ApplicationAssembleris the mostappropriate roletoperform this task.
Reveal answer details
Close answer details
Question 10
Multiple choice
Given the following client-side code that makes use of the session bean Foo: 10. @EJB Foo beanl; 11. @EJB Foo bean2; //more code here 20. booleantestl = beanl.equals(beanl); 21. booleantest2 = beanl.equals(bean2); Which two statements are true? (Choose two.)
-
A
If Foo isstateful,testlistrue, and test2 is true.
-
B
IfFoo is stateful, testlis true,andtest2isfalse.
-
C
IfFoo is stateless, testl is true, and test2 is true.
-
D
IfFoois stateful, testl is false, and test2 is false.
-
E
If Foo isstateless, testl istrue,and test2 is false.
-
F
If Fooisstateless, testl is false, andtest2is false.
Reveal answer details
Close answer details
Question 11
Multiple choice
Which two are true about specifying Java EE environment annotation metadata for session bean classes? (Choose two.)
-
A
Itis possible to inject a resource without using annotations.
-
B
Only field-level annotations can be overriden by the deployment descriptor.
-
C
Only type-level annotations can be overriden by the deployment descriptor.
-
D
Resource annotations cannot be specified on a superclass of the session bean class.
-
E
Type-level, method-level,andfield-level annotations can all beoverridden by thedeployment descriptor.
-
F
Only field-level annotations and method-level annotations can be overridden by the deployment descriptor.
Reveal answer details
Close answer details
Question 12
Single choice
A developer writes a stateless session bean FooBean with one remote business interface FooRemote containing one business method foo. Method foo takes a single parameter of application-defined type MyData. 11. public class MyData implements Java. io.Serializablej 12. int a; 13.} Method foo is implemented within the FooBean class as: 11. public void foo(MyData data) { 12. data.a = 2; 13.} Another session bean within the same application has a reference to FooRemote in variable fooRef and calls method foo with the following code: 11. MyData data = new MyDatafJ; 12. data.a = 1; 13. fooRef.foo(data); 14. System, out. println(data. a); What is the value of data, a when control reaches Line 14 of the client ?
-
A
-
B
-
C
-
D
Reveal answer details
Close answer details
Question 13
Single choice
Given : public class MyException extends Exception {} The business interface Foo declares a method work0: I. public void work0 throws MyException; The bean class FooBean contains the following: 10.©Stateless II. @Remote(Foo.class) 12. public class FooBean { 13. public void workQ throws MyException { 14. //do some work not shown here 15. throw new MyException0; 16.} Assuming there is no deployment descriptor, which statement is true when the workQ method is invoked by a client with an existing transaction context and execution reaches Line 15?
-
A
The container does notroll back thetransaction.
-
B
The clientreceives javax.ejb.EJBTransactionRequiredException.
-
C
The clientreceivesjavax.ejb.EJBTransactionRolledbackException.
-
D
Thecontainer marks the transactionforrollback by calling the EJBContext.setRollbackOnly method.
Reveal answer details
Close answer details
Question 14
Multiple choice
A session bean's business method throws an exception during execution. Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)
-
A
For application exceptions, ensure that if the current transaction commits there will be no loss of data integrity.
-
B
For application exceptions, ensurethatthe current transaction will commit.
-
C
For system errors, when the client is remote, throw a java.rmi.RemoteException that wraps the original exception.
-
D
For checked exceptions from which the bean cannot recover, throw an EJBException that wraps the original exception.
Reveal answer details
Close answer details
Question 15
Single choice
A developer implemented a Java class called Store. The class is annotated correctly to act as an entity. The developer created a stateless session bean to create, lookup, and remove Store objects. This session bean has a container-managed entity manager injected into field em and a removeStore method with transaction attribute REQUIRED. Given the following code : 32. public void re move St ore (St ore store) { 33. em.remove(store); 34.} What is a possible reason that an HlegalArgumentException is thrown at Line 33 when the removeStore method is called by a remote client?
-
A
Thepassedobject is NOT serializable.
-
B
Thepassed object is NOT found inthedatabase.
-
C
The passed object is NOT managed by the entity manager.
-
D
There is no active transaction to manage the database removal.
Reveal answer details
Close answer details
Question 16
Single choice
A developer is modifying an existing Java EE application that uses the JDBC API to access a database. This code must be used but cannot be changed, and new code needs to be added that uses the Java Persistence API. Both parts of the code will execute in the same JTA transaction. Which method of the EntityManager interface should the new code use to ensure that the data read by JDBC statements includes the state of managed entities?
-
A
Call refresh on eachchangedentity.
-
B
Callflushatthe end of each business method.
-
C
Call find before accessing any managed entity.
-
D
Calllockatthe beginning of each business method.
Reveal answer details
Close answer details
Question 17
Single choice
A CMT session bean named MrBean is annotated as follows : 21. @Stateless(name="MrBean") 22. @TransactionAttribute0"ransactionAttributeType.NOT_SUPPORTED) 23. public class MrBean { 24. public void storeStuffQ {} 25. There are no transaction annotations at the method level. Given the following snippet of an ejb-jar.xml: 23. <container-transaction> 24. <method> 25. <ejb-name>MrBean</ejb-name> 26. <method-name>storeStuff</method-name> 27. </method> 28. <transaction-attribute>Mandatory</transaction-attribute> 29. </container-transaction> Which statement is correct about the business methods in MrBean?
-
A
All methods have transactionattributeREQUIRED.
-
B
All methodshavetransaction attributeMANDATORY.
-
C
All methodshavetransaction attribute NONSUPPORTED.
-
D
Methods with name store Stuff have transaction attributeMANDATORYand all other methods have transaction attribute REQUIRED.
-
E
MethodswithnamestoreStuffhavetransaction attribute MANDATORY andall othermethods have transaction attribute NONSUPPORTED.
-
F
Methodswithname store Stuff haveatransaction attribute REQUIRED andallother methods have transaction attribute NOT SUPPORTED.
Reveal answer details
Close answer details
Question 18
Single choice
Which component can use a container-managed entity manager with an extended persistence context?
-
A
-
B
only stateful sessionbeans
-
C
only stateless session beans
-
D
session beans and web components
Reveal answer details
Close answer details
Question 19
Single choice
Which statement describes a component definition that is allowed by the EJB 3.0 specification?
-
A
A stateful session bean that is a Web service endpoint.
-
B
A stateful session bean that has one remote business interface and is a Web service endpoint.
-
C
A message-driven bean that has one message listener interface and is a Web service endpoint.
-
D
A stateless session bean that has three local business interfaces and is a Web service endpoint.
Reveal answer details
Close answer details
Question 20
Multiple choice
A developer has obtained a container-managed entity manager in a stateless session bean. Which two statements are correct? (Choose two.)
-
A
Invoking the flush method without a transaction will throw an exception.
-
B
Invoking the clear method without a transaction will throw an exception.
-
C
Invoking the persist method without a transaction will throw an exception.
-
D
Invoking the find method for an entity that does NOT exist will throw an exception.
Reveal answer details
Close answer details
Question 21
Single choice
Given : public class MyException extends Exception {} The business interface Foo declares a method work0: I.public void work0 throws MyException; The bean class FooBean contains the following: 10.©Stateless II. @Remote(Foo.class) 12. public class FooBean { 13. public void workQ throws MyException { 14. //do some work not shown here 15. throw new MyException0; 16.} Assuming there is no deployment descriptor, which statement is true when the workQ method is invoked by a client with an existing transaction context and execution reaches Line 15?
-
A
The container does notroll back thetransaction.
-
B
The clientreceives javax.ejb.EJBTransactionRequiredException.
-
C
The clientreceivesjavax.ejb.EJBTransactionRolledbackException.
-
D
Thecontainer marks the transactionforrollback by calling the EJBContext.setRollbackOnly method.
Reveal answer details
Close answer details
Question 22
Single choice
A developer is working on a user registration application using EJB 3.0. A business method registerUser in stateless session bean RegistrationBean performs the user registration. The registerUser method executes in a transaction context started by the client. If some invalid user data causes the registration to fail, the client invokes registerUser again with corrected data using the same transaction. Which design can meet this requirement?
-
A
Have registerUser method call EJBContext.setRollbackOnlyOmethodafter registration fails.
-
B
Have registerUser method throw javax.ejb.EJBTransactionRequiredExceptionafterregistration fails.
-
C
HaveregisterUser method throw EJBException without marking the transaction for rollback, after registration fails.
-
D
Create an application exception withtherollbackattributeset to falseandhave registerUser method throwit afterregistration fails.
Reveal answer details
Close answer details
Question 23
Single choice
Which statement describes a component definition that is allowed by the EJB 3.0 specification?
-
A
A stateful session bean that is a Web service endpoint.
-
B
A stateful session bean that has one remote business interface and is a Web service endpoint.
-
C
A message-driven bean that has one message listener interface and is a Web service endpoint.
-
D
A stateless session bean that has three local business interfaces and is a Web service endpoint.
Reveal answer details
Close answer details
Question 24
Multiple choice
A session bean's business method throws an exception during execution. Which two are responsibilities of the Bean Provider when throwing the exception? (Choose two.)
-
A
For application exceptions, ensure that if the current transaction commits there will be no loss of data integrity.
-
B
For application exceptions, ensurethatthe current transaction will commit.
-
C
For system errors, when the client is remote, throw a java.rmi.RemoteException that wraps the original exception.
-
D
For checked exceptions from which the bean cannot recover, throw an EJBException that wraps the original exception.
Reveal answer details
Close answer details
Question 25
Single choice
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.
Reveal answer details
Close answer details
Question 26
Single choice
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 of a JTA transaction.
-
D
A new persistence context begins when the entity manager is invoked in the context of a resource-local transaction.
Reveal answer details
Close answer details
Question 27
Multiple choice
Which two can be specified by both the Bean Provider and the Application Assembler? (Choose two.)
-
A
-
B
-
C
-
D
session bean's state-management type
-
E
enterprise bean's remote home interface
-
F
enterprise bean's local business interface
Reveal answer details
Close answer details
Question 28
Single choice
A developer wants to perform programmatic access control inside EJB 3.0 session beans. This is needed because some permissions can be determined only at application runtime. Which method achieves this goal?
-
A
javax.ejb.EJBContext.getRollbackOnlyO
-
B
java.lang.SecurityManager.checkAccess(Thread t)
-
C
javax. interceptor. InvocationContext. getTargetO
-
D
javax. ejb. SessionContext.isCallerlnRole(String roleName)
-
E
javax. servlet. http. HttpServletRequest. getUserPrincipalQ
Reveal answer details
Close answer details
Question 29
Single choice
The execution of the find method in the following code throws an exception: 11. em.find(Customer.class, custld); 12. //Where em is a reference to a extended scoped entity manager. Which scenario can cause the exception?
-
A
Thefindmethod was called without a transaction.
-
B
Theentity corresponding to therequestedprimary key has been removed.
-
C
The entity corresponding to therequestedprimarykeyhas beendetached.
-
D
The data type of custld is NOT a valid type fortheCustomer entity primary key.
Reveal answer details
Close answer details
Question 30
Single choice
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.
Reveal answer details
Close answer details
Question 31
Multiple choice
Given the following client-side code that makes use of the session bean Foo: 10. @EJB Foo beanl; 11. @EJB Foo bean2; //more code here 20. booleantestl = beanl.equals(beanl); 21. booleantest2 = beanl.equals(bean2); Which two statements are true? (Choose two)
-
A
A. IfFoo is stateful, testl is true, and test2 is true,
-
B
If Foo is stateful, testl is true, and test2 is false,
-
C
If Foo is stateless, testl is true, and test2 is true.
-
D
If Foo is stateful, testl is false, and test2 is false,
-
E
If Foo is stateless, testl is true, and test2 is false.
-
F
If Foo is stateless, testl is false, and test2 is false
Reveal answer details
Close answer details
Question 32
Single choice
A developer wants to perform programmatic access control inside EJB 3.0 session beans. This is needed because some permissions can be determined only at application runtime. Which method achieves this goal?
-
A
javax.ejb.EJBContext.getRollbackOnlyO
-
B
java.lang.SecurityManager.checkAccess(Thread t)
-
C
javax. interceptor. InvocationContext. getTargetO
-
D
javax. ejb. SessionContext.isCallerlnRole(String roleName)
-
E
javax. servlet. http. HttpServletRequest. getUserPrincipalQ
Reveal answer details
Close answer details
Question 33
Multiple choice
A developer creates a stateful session bean that is used by many concurrent clients. The clients are written by other development teams and it is assumed that these clients might not remove the bean when ending their session. The number of concurrent sessions will be greater than the defined bean cache size. The developer must consider that the state of the session bean can be influenced by either passivation or timeout. Which three actions should the developer take to make the bean behave correctly in passivation and timeout situations? (Choose three.)
-
A
Release references to resources ina@Removeannotated method.
-
B
Re-establish references to resources in an @lnit annotated method.
-
C
Release references to resources ina@PreDestroy annotated method.
-
D
Release references to resources in a @PrePassivate annotated method.
-
E
Re-establish referencestoresources ina (©PostActivate annotatedmethod.
Reveal answer details
Close answer details
Question 34
Single choice
Which example of Java Persistence identity definitions is portable and correct assuming NO mapping descriptor is present?
-
A
©Entity public class A { @ld private float id; // more code here }
-
B
@ldClass(com. acme. LineltemPK. class) ©Entity public class Lineltem { @ld int orderld; @ld int lineltemld; // more code here }
-
C
@Entity public class Project { @ld@GeneratedValue(strategy=TABLE) public String getProjectldQ {return pid;} // more code here }
-
D
©Entity public class Employee { @ld public Java.util.Date getBirthdayO {return bday;} // more code here
Reveal answer details
Close answer details
Question 35
Single choice
A developer is designing a Java Persistence application that is mapped to a set of existing tables. This set includes table EMPLOYEE, DEPARTMENT, and PROJECT. Tables EMPLOYEE and DEPARTMENT do NOT define any foreign key constraints to table PROJECT. Table PROJECT defines foreign key constraints with references to tables EMPLOYEE and DEPARTMENT and an extra column called COST. The table EMPLOYEE is mapped to an entity Employee and the table DEPARTMENT to an entity Department. How can the table PROJECT be mapped so the persistence application can be portable?
-
A
Such sets of tables cannotbemappedandkeep the application portable.
-
B
Map thetablePROJECT asasecondary table for either the Employee or Departmententity.
-
C
Map the table PROJECT to bidirectional many-to-many relationships between the Employeeand Departmentusing a Java. util.Mapas the type ofthefield or property.
-
D
Mapthe tablePROJECT to an entity Projectwith afield or property cost mappedto thecolumn COST and one-to-many relationshipstothis entity in the Employee and the Department.
Reveal answer details
Close answer details
Question 36
Single choice
A developer is working on a user registration application using EJB 3.0. A business method registerUser in stateless session bean RegistrationBean performs the user registration. The registerUser method executes in a transaction context started by the client. If some invalid user data causes the registration to fail, the client invokes registerUser again with corrected data using the same transaction. Which design can meet this requirement?
-
A
Have registerUser method call EJBContext.setRollbackOnlyOmethodafter registration fails.
-
B
Have registerUser method throw javax.ejb.EJBTransactionRequiredExceptionafterregistration fails.
-
C
HaveregisterUser method throw EJBException without marking the transaction for rollback, after registration fails.
-
D
Create an application exception withtherollbackattributeset to falseandhave registerUser method throwit afterregistration fails.
Reveal answer details
Close answer details
Question 37
Single choice
Which is a valid way of injecting a container-managed transaction-scoped persistence context into an EJB 3.0 session bean assuming the application contains only one persistence unit?
-
A
@PersistenceUnit public EntityManager em;
-
B
@PersistenceContext private EntityManager em;
-
C
@TransactionManagement(TransactionManagementType. CONTAINER) public EntityManager em;
-
D
@Resource(name="persistence/em", authenticationType=AuthenticationType. CONTAINER) protected EntityManager em;
Reveal answer details
Close answer details
Question 38
Multiple choice
The bean class of an EJB Web service endpoint has one method annotated with @WebMethod. Which two types can be legally returned from that method? (Choose two.)
-
A
-
B
-
C
an array ofJava.lang. String
-
D
an EJB3.0local businessinterfacereference
-
E
an EJB3.0 remotebusiness interfacereference
Reveal answer details
Close answer details
Question 39
Single choice
A developer obtains a Java, security. Principal object by calling the SessionContext.getCallerPrincipal method from within a business method of a session bean. Which statement is true?
-
A
The returned Principal object can be null.
-
B
The roles which the Principal is in can be determined from this Principal object.
-
C
The return value of Principal. getName depends on the security realm which was used to authenticate thecaller.
-
D
The return value of the Principal. getName method is exactly the same as the username used for authentication of the caller.
Reveal answer details
Close answer details
Question 40
Single choice
A User entity is in a one-to-many relationship with a Book entity. Assume that a developer has a function fetchBook(String title) that fetches a Book entity with the given title title. Also assume that the developer has an entity manager em. Which query can be used to return the user that holds the book titled "Java"?
-
A
em.createQuery("SELECT u FROM User u where :great IN u.books.title").setParameter("great", "Java")
-
B
em.createQuery("SELECT u FROM User u where :great IN u.books").setParameter("great", fetchBook("Java"))
-
C
em.createQuery("SELECT u FROM User u where :great MEMBER OF u.books.title").setParameter("great", "Java")
-
D
em.createQuery("SELECT u FROM User u where :great MEMBER OF u.books").setParameter("great", fetchBook("Java"))
Reveal answer details
Close answer details
Question 41
Single choice
A developer wants to achieve the following two behaviors for an EJB 3.0 session bean: (1) If the client calls a business method with a transaction context, the container will invoke the enterprise bean's method in the client's transaction context. (2) If the client calls a business method without a transaction context, the container will throw the javax. ejb. EJBTransactionRequiredException. Which transaction attribute should be used?
-
A
-
B
-
C
-
D
-
E
Reveal answer details
Close answer details
Question 42
Multiple choice
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
Theflushmode is NOT explicitly set.
-
B
Theflushmodeon the Query object is set toCOMMIT.
-
C
The refresh method on the EntityManager is called.
-
D
The flush mode on the persistence context issetto AUTO but is NOT specified for the Query object.
Reveal answer details
Close answer details
Question 43
Single choice
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.
Reveal answer details
Close answer details
Question 44
Single choice
Which statement about the combination of mapping defaults, annotations, and XML descriptors is correct?
-
A
All mapping annotations must always be processed by the persistence provider.
-
B
Some annotations, like the @Entity annotation, must always be processed by the persistence provider.
-
C
The mapping information for an entity class specified by annotations and in XML descriptors must be distinct.
-
D
If multiple entity listeners are defined, the order in which they are invoked can be defined or overwritten in the XML descriptor.
Reveal answer details
Close answer details
Question 45
Single choice
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.
Reveal answer details
Close answer details
Question 46
Single choice
A developer is working on a project that includes both EJB 2.1 and EJB 3.0 session beans. A lot of business logic has been implemented and tested in these EJB 2.1 session beans. Some EJB 3.0 session beans need to access this business logic. Which design approach can achieve this requirement?
-
A
Add adapted home interfaces to EJB 3.0 session beans to make EJB 3.0 and EJB 2.1 session beans interoperable.
-
B
Add EJB 3.0 business interfaces to existing EJB 2.1 session beans and inject references to these business interfaces into EJB 3.0 session beans.
-
C
No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 home interface into the EJB 3.0 bean class.
-
D
No need to modify existing EJB 2.1 session beans. Use the @EJB annotation to inject a reference to the EJB 2.1 component interface into the EJB 3.0 bean class.
Reveal answer details
Close answer details
|