Spring MCQ Quiz Hub

Spring Mcq Set 12

Choose a topic to test your knowledge and improve your Spring skills

For mapping and persisting your objects with Hibernate and JPA.





✅ Correct Answer: 4

Core Programming Elements for Different Data Access Strategies.





✅ Correct Answer: 4

Interface whose instances can be obtained from a SessionFactory instance.





✅ Correct Answer: 1

Interface whose instances can be obtained from an EntityManagerFactory instance.





✅ Correct Answer: 2

The exceptions thrown by Hibernate are of type HibernateException, while those thrown by JPA may be of type PersistenceException.





✅ Correct Answer: 1

To accept a session factory via dependency injection.





✅ Correct Answer: 1

Property for factory bean to load the Hibernate configuration file.





✅ Correct Answer: 3

If you want to use this data source for your session factory, you can inject it into the dataSource property of LocalSessionFactoryBean.





✅ Correct Answer: 1

FactoryBean to create an entity manager factory in the IoC container.





✅ Correct Answer: 1

It allows you to override some of the configurations in the JPA configuration file.





✅ Correct Answer: 2

Spring HibernateTemplate can simplify your DAO implementation by managing sessions and transactions for you.





✅ Correct Answer: 1

An alternative to Spring HibernateTemplate is:-





✅ Correct Answer: 2

Sessionfactory can manage contextual sessions for you and allows you to retrieve them by the:-





✅ Correct Answer: 3

DAO methods require access to the session factory, which can be injected:-





✅ Correct Answer: 4

DAO methods must be made transactional.





✅ Correct Answer: 1

Annotation to find a transaction and then fail, complaining that no Hibernate session been bound to the thread.





✅ Correct Answer: 2

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:-





✅ Correct Answer: 3

HibernateTemplate will translate the native Hibernate exceptions into exceptions in Spring DataAccessException hierarchy.





✅ Correct Answer: 1

Annotation for Hibernate exceptions to be translated into Spring DataAccessException for consistent exception handling:-





✅ Correct Answer: 3

Instance to translate the native Hibernate exceptions into data access exceptions in Spring DataAccessException hierarchy.





✅ Correct Answer: 4

You can assign a component name in this annotation and have the session factory autowired by the Spring IoC container with @Autowired.





✅ Correct Answer: 1

Spring provides to simplify your DAO implementation by managing entitymanagers and transactions for you:-





✅ Correct Answer: 2

Annotation used for entity manager injection in EJB components.





✅ Correct Answer: 1

To use the context injection approach, you can declare an entity manager field in your DAO and annotate it with the @PersistenceContext annotation.





✅ Correct Answer: 1

JpaTemplate will translate the native JPA exceptions into exceptions in Spring DataAccessException hierarchy.





✅ Correct Answer: 1

Transactions can be described with key properties:-





✅ Correct Answer: 4

To access a database running on the Derby server, you have to add:-





✅ Correct Answer: 1

Spring’s transaction support offers a set of technology-independent facilities, including transaction managers.





✅ Correct Answer: 3

Spring’s core transaction management abstraction is based on the interface:-





✅ Correct Answer: 2

The PlatformTransactionManager interface provides methods for working with transactions:





✅ Correct Answer: 4

Spring has several built-in implementations of PlatformTransactionManager interface for use with different transaction management APIs.





✅ Correct Answer: 1

A transaction manager is declared in the Spring IoC container as a normal bean.





✅ Correct Answer: 1

Method that allows you to start a new transaction (or obtain the currently active transaction).





✅ Correct Answer: 1

PlatformTransactionManager is an abstract unit for transaction management.





✅ Correct Answer: 1

Method to start a new transaction with that definition:-





✅ Correct Answer: 1

To help you control the overall transaction management process and transaction exception handling.





✅ Correct Answer: 2

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.





✅ Correct Answer: 1

A TransactionTemplate can accept a transaction callback object that implements:-





✅ Correct Answer: 3

Spring (since version 2.0) offers a transaction advice that can be easily configured via the:-





✅ Correct Answer: 3

You can omit the transaction-manager attribute in the element if your transaction manager has the name transactionManager.





✅ Correct Answer: 1

A transaction propagation behavior can be specified by the:-





✅ Correct Answer: 1

Transaction propagation behavior are defined in the:-





✅ Correct Answer: 2

If there’s an existing transaction in progress, the current method should run within this transaction.





✅ Correct Answer: 1

The current method must start a new transaction and run within its own transaction.





✅ Correct Answer: 2

If there’s an existing transaction in progress, the current method can run within this transaction.





✅ Correct Answer: 3

The current method should not run within a transaction.





✅ Correct Answer: 4

The current method must run within a transaction.





✅ Correct Answer: 2

The current method should not run within a transaction. If there’s an existing transaction in progress, an exception will be thrown.





✅ Correct Answer: 4

If there’s an existing transaction in progress, the current method should run within the nested transaction.





✅ Correct Answer: 3

For two transactions T1 and T2, T1 reads a field that has been updated by T2 but not yet committed.





✅ Correct Answer: 1