1.
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:
1.checkGoods 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?
2.
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.Serializable {
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 MyData();
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 ?
3.
Given two entitles with a many-to-many bidirectional association between them:
11. @Entity public class Employee {
12. Collection projects;
13. //more code here
14. }
and
11. @Entity public class Project{
12. Set
14. }
13. //more code here emps;
What set of annotations correctly defines the association?
4.
An application wants to utilize side. effects of cascading entity-manager operations to related entities. Which statement is correct?
5.
A session bean calls the setRollbackOnly method on the EJBContext interface within a business method with an active transaction. Which two are correct? (Choose two.)
6.
FooBean and BarBean are both EJB 3.0 stateless session beans with container-managed transaction demarcation. All business methods in the two beans have
transaction attribute REQUIRED. The business method foo in FooBean invokes the business method bar in BarBean.
Given:
10. public class BarBean {
11. public void bar() {
12. throw new EJBException("unexpected error...");
13. }
Which statement is true about the result of this method invocation assuming execution reaches Line 12?
7.
A developer writes a stateless session bean FooBean and uses its deployment descriptor to declare a local ejb dependency on a stateful session bean in the same
ejB. jar.
Which environment annotation, when declared within the FooBean bean class, is equivalent to the ejB. local-ref shown above?
8.
A developer wants to write a stateful session bean using the following interface as local business interface:
1. package acme;
2. public interface Bar {
3. public void bar();
4. }
Assuming there is NOT an ejB. jar.xml file, which code can be inserted into Lines 4-6 below to define the bean with the ejb name of BarBean?
1. package acme;
2. import javax.ejb.*;
3. import java.io.*;
4.
5.
6.
7. }
9.
Given the following stateful session bean:
10.@Stateful
11. public class VideoBean implements Video {
12. public void methodA() {} 13.
14. @TransactionAttribute(TransactionAttributeType.SUPPORTS)
15. public void methodB() {}
16.
17. public void methodC() {}
18. @TransactionAttribute(TransactionAttributeType.REQUIRED)
19.
20. public void methodD() {}
21.}
Assuming no other transaction-related metadata, which is true?
10.
Which is the correct way of declaring bean-managed transaction demarcation for an EJB 3.0 message. driven bean?