How to integrate spring with hibernate using annotations?



How to integrate spring with hibernate using annotations?..

Answer / Atul Yadav

To integrate Spring and Hibernate using annotations, you should:
1. Add Hibernate dependencies to your project.
2. Configure a DataSource or JPA provider in your Spring configuration file or Java Configuration class.
3. Define the Hibernate session factory bean in your Spring configuration file or use @EnableTransactionManagement and @Autowired the session factory if you are using annotations.
4. Annotate your DAO classes with @Repository, your service classes with @Service, and your controller classes with @Controller.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Spring Framework Interview Questions

What is difference between @component and @controller?

1 Answers  


Why do we need spring batch?

1 Answers  


What is a spring ioc container?

1 Answers  


Can we learn spring boot without knowing spring? : Spring Boot

1 Answers  


What is a spring component?

1 Answers  


What do you understand as dependency injection (di)?

1 Answers  


What is the default bean scope within spring?

1 Answers  


How many types of dependency injection are there in spring?

1 Answers  


What is the difference between @qualifier and @primary?

1 Answers  


What is tasklet in spring batch?

1 Answers  


How do you write an annotation?

1 Answers  


Differentiate between beanfactory and applicationcontext.

1 Answers  


Categories