adspace


How to integrate spring with hibernate using annotations?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is lazy class?

490


What is difference between @controller and @restcontroller in spring?

556


How can you inject java collection in spring?

518