R4RIN
MCQS
Spring MCQ Quiz Hub
Spring Mcq Set 12
Choose a topic to test your knowledge and improve your Spring skills
1. For mapping and persisting your objects with Hibernate and JPA.
Using the Hibernate API to persist objects with Hibernate XML mappings
Using the Hibernate API to persist objects with JPA annotations
Using JPA to persist objects with JPA annotations
all of the mentioned
2. Core Programming Elements for Different Data Access Strategies.
Resource
Resource Factory
Session
All of the mentioned
3. Interface whose instances can be obtained from a SessionFactory instance.
Session
Session Factory
All of the mentioned
none of the mentioned
4. Interface whose instances can be obtained from an EntityManagerFactory instance.
Entity
EntityManager
All of the mentioned
None of the mentioned
5. The exceptions thrown by Hibernate are of type HibernateException, while those thrown by JPA may be of type PersistenceException.
True
False
none
all the mentoined
6. To accept a session factory via dependency injection.
HibernateCourseDao
HibernateCourse
HibernateDao
All of the mentioned
7. Property for factory bean to load the Hibernate configuration file.
config.xml
config
configLocation
None of the mentioned
8. If you want to use this data source for your session factory, you can inject it into the dataSource property of LocalSessionFactoryBean.
True
False
none
all the mentoined
9. FactoryBean to create an entity manager factory in the IoC container.
LocalEntityManagerFactoryBean
LocalEntityManagerFactory
LocalEntityManager
all of the mentioned
10. It allows you to override some of the configurations in the JPA configuration file.
LocalEntityManagerFactoryBean
LocalContainerEntityManagerFactoryBean
All of the mentioned
None of the mentioned
11. Spring HibernateTemplate can simplify your DAO implementation by managing sessions and transactions for you.
True
False
none
all the mentoined
12. An alternative to Spring HibernateTemplate is:-
HibernateContext
Hibernate contextual sessions
All of the mentioned
None of the mentioned
13. Sessionfactory can manage contextual sessions for you and allows you to retrieve them by the:-
getSession() method
getCurrent() method
getCurrentSession() method
none of the mentioned
14. DAO methods require access to the session factory, which can be injected:-
a setter method
constructor argument
none of the mentioned
all of the mentioned
15. DAO methods must be made transactional.
True
False
none
all the mentoined
16. Annotation to find a transaction and then fail, complaining that no Hibernate session been bound to the thread.
@Transaction
@Transactional
@Transactions
none of the mentioned
17. In the bean configuration file for Hibernate (i.e., beans-hibernate.xml), you have to declare a HibernateTransactionManager instance for this application and enable declarative transaction via:-
tx:annotation
tx:annotationdriven
tx:annotation-driven
none of the mentioned
18. HibernateTemplate will translate the native Hibernate exceptions into exceptions in Spring DataAccessException hierarchy.
True
False
none
all the mentoined
19. Annotation for Hibernate exceptions to be translated into Spring DataAccessException for consistent exception handling:-
@Translation
@Repo
@Repository
None of the mentioned
20. Instance to translate the native Hibernate exceptions into data access exceptions in Spring DataAccessException hierarchy.
PersistenceExceptionPostProcessor
PersistenceExceptionTranslation
PersistenceException
PersistenceExceptionTranslationPostProcessor
21. You can assign a component name in this annotation and have the session factory autowired by the Spring IoC container with @Autowired.
True
False
none
all the mentoined
22. Spring provides to simplify your DAO implementation by managing entitymanagers and transactions for you:-
HibernateTemplate
JpaTemplate
SpringTemplate
None of the mentioned
23. Annotation used for entity manager injection in EJB components.
@PersistenceContext
@Persistence
@Persistence
None of the mentioned
24. To use the context injection approach, you can declare an entity manager field in your DAO and annotate it with the @PersistenceContext annotation.
True
False
none
all the mentoined
25. JpaTemplate will translate the native JPA exceptions into exceptions in Spring DataAccessException hierarchy.
True
False
none
all the mentoined
26. Transactions can be described with key properties:-
Atomicity
Consistency
Isolation
all of the mentioned
27. To access a database running on the Derby server, you have to add:-
Derby client library
Tomcat client library
All of the mentioned
None of the mentioned
28. Spring’s transaction support offers a set of technology-independent facilities, including transaction managers.
org.springframework.transaction.PlatformTransactionManager
org.springframework.transaction.support.TransactionTemplate
all of the mentioned
None of the mentioned
29. Spring’s core transaction management abstraction is based on the interface:-
PlatformTransaction
PlatformTransactionManager
TransactionManager
PlatformManager
30. The PlatformTransactionManager interface provides methods for working with transactions:
getTransaction(TransactionDefinition definition)
commit(TransactionStatus status)
rollback(TransactionStatus status)
All of the mentioned
31. Spring has several built-in implementations of PlatformTransactionManager interface for use with different transaction management APIs.
True
False
none
all the mentoined
32. A transaction manager is declared in the Spring IoC container as a normal bean.
True
False
none
all the mentoined
33. Method that allows you to start a new transaction (or obtain the currently active transaction).
getTransaction()
commit()
rollback()
All of the mentioned
34. PlatformTransactionManager is an abstract unit for transaction management.
True
False
none
all the mentoined
35. Method to start a new transaction with that definition:-
getTransaction()
commit()
rollback()
None of the mentioned
36. To help you control the overall transaction management process and transaction exception handling.
SpringTransactionTemplate
TransactionTemplate
Transaction
None of the mentioned
37. You just have to encapsulate your code block in a callback class that implements the TransactionCallback interface and pass it to the TransactionTemplate execute method for execution. In this way, you don’t need to repeat the boilerplate transaction management code for this block.
True
False
none
all the mentoined
38. A TransactionTemplate can accept a transaction callback object that implements:-
TransactionCallback
TransactionCallbackWithoutResult class
All of the mentioned
None of the mentioned
39. Spring (since version 2.0) offers a transaction advice that can be easily configured via the:-
rx:advice
bx:advice
tx:advice
None of the mentioned
40. You can omit the transaction-manager attribute in the element if your transaction manager has the name transactionManager.
True
False
none
all the mentoined
41. A transaction propagation behavior can be specified by the:-
propagation
consistency
isolation
All of the mentioned
42. Transaction propagation behavior are defined in the:-
org.springframework.transaction.Transaction
org.springframework.transaction.TransactionDefinition
all of the mentioned
None of the mentioned
43. If there’s an existing transaction in progress, the current method should run within this transaction.
Required
REQUIRES NEW
SUPPORTS
NOT SUPPORTED
44. The current method must start a new transaction and run within its own transaction.
Required
REQUIRES NEW
SUPPORTS
NOT SUPPORTED
45. If there’s an existing transaction in progress, the current method can run within this transaction.
Required
REQUIRES NEW
SUPPORTS
NOT SUPPORTED
46. The current method should not run within a transaction.
Required
REQUIRES NEW
SUPPORTS
NOT SUPPORTED
47. The current method must run within a transaction.
Required
MANDATORY
SUPPORTS
NOT SUPPORTED
48. The current method should not run within a transaction. If there’s an existing transaction in progress, an exception will be thrown.
Required
MANDATORY
SUPPORTS
NEVER
49. If there’s an existing transaction in progress, the current method should run within the nested transaction.
Required
MANDATORY
NESTED
NEVER
50. For two transactions T1 and T2, T1 reads a field that has been updated by T2 but not yet committed.
Dirty Read
Nonrepeatable read
Phantom read
Lost Updates
Submit