0% found this document useful (0 votes)
4 views1 page

Java Ques4

Autowiring in Spring allows for automatic injection of beans without explicit logic, with modes including no, byName, byType, and constructor. Spring also defines bean scopes such as singleton, prototype, request, session, and globalsession, each serving different lifecycle needs. Additionally, Spring supports programmatic and declarative transaction management, and the JdbcTemplate simplifies database operations by reducing boilerplate code.

Uploaded by

Paoli Bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Java Ques4

Autowiring in Spring allows for automatic injection of beans without explicit logic, with modes including no, byName, byType, and constructor. Spring also defines bean scopes such as singleton, prototype, request, session, and globalsession, each serving different lifecycle needs. Additionally, Spring supports programmatic and declarative transaction management, and the JdbcTemplate simplifies database operations by reducing boilerplate code.

Uploaded by

Paoli Bose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

==>>What is autowiring in spring? What are the autowiring modes?

Autowiring enables the programmer to inject the bean automatically. We don't need
to write explicit injection logic.

No. Mode Description


1) no this is the default mode, it means autowiring is not enabled.
2) byName injects the bean based on the property name. It uses setter
method.
3) byType injects the bean based on the property type. It uses setter
method.
4) constructor It injects the bean using constructor

==>> What are the different bean scopes in spring?

1) singleton The bean instance will be only once and same instance will be
returned by the IOC container. It is the default scope.
2) prototype The bean instance will be created each time when requested.
3) request The bean instance will be created per HTTP request.
4) session The bean instance will be created per HTTP session.
5) globalsession The bean instance will be created per HTTP global session.
It can be used in portlet context only.

==>> In which scenario, you will use singleton and prototype scope?

Singleton scope should be used with EJB stateless session bean and prototype scope
with EJB stateful session bean.

==>> What are the transaction management supports provided by spring?

Programmatic Transaction Management: should be used for few transaction operations.


Declarative Transaction Management: should be used for many transaction operations.

==>>What are the advantages of JdbcTemplate in spring?

Less code: By using the JdbcTemplate class, you don't need to create
connection,statement,start transaction,
commit transaction and close connection to execute different queries. You can
execute the query directly.

==>>How can you fetch records by spring JdbcTemplate?

You can fetch records from the database by the query method of JdbcTemplate. There
are two interfaces to do this:

ResultSetExtractor
RowMapper

==>>

You might also like