FooBean and BarBean are both EJB 3.0 stateless beans with container-managed transaction demarcation. All business methods in FooBean have transaction attribute
REQUIRED, and all business methods in BarBean have transaction attribute
REQUIRED_NEW. 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 RuntimeException (unexpected error . . . );
13. }}
Which is true about the method of invocation assuming execution reaches line 12?
Answer : A
Given two entities with many-to-many bidirectional association between them:
Answer : C
Explanation: http://uaihebert.com/jpa-manytomany-unidirecional-e-bidirecional/
An application wants to utilize side effects of cascading entity manager operations to related entities.
Which statement is correct?
Answer : C
Reference:http://stackoverflow.com/questions/4748426/cannot-remove-entity-which-is- target-of-onetoone-relation(answer 1)
A developer wants to model the grades for a student as a Map<course, integer>. Assume that Student and Course are entitles, and that grades are modeled by integers.
Which of the following two statements are correct? (Choose two)
Answer : A,D
Explanation: http://www.objectdb.com/api/java/jpa/MapKeyColumn
An entity person is mapped to a table PERSON and has a collection-valued persistence field otherUsedNames that stores names used by a person. The other used Names field is mapped to a separate table called NAMES. Which code fragment correctly defines such field?
Answer : D
Reference:http://docs.oracle.com/javaee/6/api/javax/persistence/CollectionTable.html
A developer who is designing entity classes to map a legacy database encounters a table called STUDENT_RECORD.
This table has two columns, STUDENT_ID and STUDENT_INFO_ID. The primary key of this table consists of both columns, and there is a unique constraint on each info column.
The STUDENT_ID column is foreign key to the STUDENT table and STUDENT_INFO_ID column is a foreign key to the STUDENT_DAT table.
What entity classes and relationships can the developer use to model these tables and relationship?(Choose two)
Answer : A,C
Given:
Answer : C
Given two entities with one to-one association:
Answer : C
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?
Answer : A
Explanation: http://docs.oracle.com/javaee/6/api/javax/ejb/TransactionAttributeType.html
QUESTIONNO:34 -
WhichEntityManagerAPIwilllockentityxwithapessimisticlock?
A.em.lock(x,LockModeType.WRITE)
B.em.lock(x,LockModeType.PESSIMISTIC)
C.em.lock(x,LockModeType.PESSIMISTIC_READ)
D.em.lock(x,LockModeType.OPTIMISTIC_FORCE_INCREMENT)
Answer:C -
Reference:http://www.objectdb.com/java/jpa/persistence/lock#Pessimistic_Locking_(pessi misticlocking)
QUESTIONNO:35 -
ItaPersistenceapplicationlocksentityxwithapessimisticlock,whichstatementistrue?
A.Persistenceprovidercandeferobtainingthelockuntilthenextsynchronizationofanentitytothed atabase
B.APersistenceproviderwillobtainthelockwhentheentityisrefreshedfromthedatabase
C.APersistenceproviderisnotrequiredtosupporttheLockModeType.PESSIMISTIC_WRITEloc kingtype
D.Ifalockcannotbeobtained,thePersistenceprovidermustthrowanexception
Answer:D -
Reference:http://www.eclipse.org/eclipselink/api/2.0/javax/persistence/LockModeType.html
Explanation -
:Whenthelockcannotbeobtained,andthedatabaselockingfailureresultsintransaction- levelrollback,theprovidermustthrowthePessimisticLockExceptionandensurethattheJTAtrans actionorEntityTransactionhasbeenmarkedforrollback.
QUESTIONNO:36 -
IfaPersistenceapplicationlocksentityxwithaLockModeType.OPTIMISTIC_FORCEINCREME
NTlocktype,whichstatementistrue?
A.ThePersistenceapplicationmustincrementtheversionvaluepriortolockingtheentity.
B.ThisoperationwillresultinaPersistentLockExceptionforanon-versionedobject.
C.ThisoperationwillresultinaPersistentLockExceptioniftheversionchecksfail.
D.LockModeType.OPTIMISTIC_FORCE_INCREMENTisthesynonymoftheLockModeType.
WRITElocktype.
Answer:D -
Reference:http://docs.oracle.com/javaee/6/tutorial/doc/gkjiu.html(seventhrowinthefirsttableo nthepage)
QUESTIONNO:37 -
PersistenceapplicationlocksentityxwithaLockModeType.PESSIMISTIC_READlocktype,whic hstatementistrue?
A.Thisoperationwillforceserializationamongtransactionsattemptingtoreadtheentitydata.
B.ThisoperationwillresultinaTransactionRolledbackExceptionifthelockcannotbeobtained.
C.Iftheapplicationlaterupdatestheentity,andthechangesareflushedtothedatabase,thelockwill beconvertedtoanexclusivelock.
D.LockModeType.PESSIMISTIC_READisthesynonymoftheLockModeType.READ.
Answer:C -
QUESTIONNO:38 -
Auserentityisretrievedinaqueryandstoredinaninstancevariableuser.Theuserentityhasasingle valuednamepropertythatusesthemappingdefaults,andaphotoproperty,whichislazilyloaded.T heapplicationthencallsthefollowingmethod:
PersistenceUtil.isLoaded(user);
Whichtwoofthefollowingstatementsarecorrect?
A.Thenamepropertywasloadedfromthedatabase.
B.ThenamepropertywasNOTbeloadedfromthedatabase.
C.Thenamepropertymayormaynothavebeenloadedfromthedatabase.
D.Thephotopropertywasloadedfromthedatabase.
E.ThephotopropertywasNOTloadedfromthedatabase.
F.Thephotopropertymayormaynothavebeenloadedfromthedatabase.
Answer:A,F -
Reference:http://docs.oracle.com/javaee/6/api/javax/persistence/PersistenceUtil.html http://stackoverflow.com/questions/10437552/what-does-persistenceutil-
Which cascade option can be specified in a mapping descriptor so that it applies to all relationships in a persistent e unit?
Answer : D
Reference:http://netbeans.org/bugzilla/show_bug.cgi?id=172098(second yellow box on the page)
An application that uses pessimistic locking calls an updateData method that results in a
LockTimeoutException being thrown. What three statements are correct? (Choose three)
Answer : A,D,F
If an application uses an extended persistence context, which of the following is true?
Answer : C
Reference:http://java.boot.by/scbcd5-guide/ch07s03.html
The Contact Information embeddable class contains address information as well as a reference to a phone entity. The ContactInformation class is defined as follows:
@Embeddable public class ContactInformation {
String street;
String city;
@OneToOne Phone phone;
The developer wants to use this class in an Employee entity, but override the default name of the foreign key to the Phone entity. Which of the code segments shows how to do this correctly?
Answer : A
Reference:http://docs.oracle.com/javaee/6/api/javax/persistence/AssociationOverride.html
A developer has created an application managed entity manager.
Which statement is correct?
Answer : A
Reference:http://docs.oracle.com/javaee/6/tutorial/doc/bnbqw.html#bnbra
Which statement is true about the @OrderColumn annotation?
Answer : D
Reference:http://www.eclipse.org/eclipselink/api/2.0/javax/persistence/OrderColumn.html(s econd paragraph)