Unfortunately, there are multiple ways to implement a DAO in Spring. And you have to pick one
Hibernate - Spring allows you to intialize the SessionFactory in the configuration, and takes care of obtaining Session, and managing transaction for you. The DAO that you impelment will have a Session injected into it, and all you do inside the DAO is the data access operations, without worrying about getting Session and opening transaction
JPA - Similarily, If you choose to use JPA, Spring allows you to define a EntityManagerFactory in the Spring configuration, and manages transaction.
Spring Data JPA - Spring Data is a Spring project that allows you to eliminate most of the code in your DAO. You basically just write the JQL queries
To learn about how to use Hibernate and JPA directly, look here. To learn about Spring Data JPA, look here
posted 4 years ago
Thanks Jayesh for pointers.
and i am also looking at some examples/exercises on spring to get well versed with it all the concepts.
I know theoretically much about the spring concepts but i feel getting hands-on with problem makes much difference.
do you think spring.io docs should be good to try out ? please do suggest if any links you thinks useful.
Spring.io docs are the official docs from Spring. I prefer to use them because Spring has gone through so many changes that if you look for information online, 10 places will give you 12 answers for the same question. Spring.io tells you what the recommended solution is based on the version of Spring that you are using.
The problem with spring.io reference is that it doesn't give a complete example. You cannot copy-paste-tweak. A lot of blogs like mykong have complete examples that you can copy-paste, but sometimes he posts annoyingly wrong solutions.
crispy bacon. crispy tiny ad:
how do I do my own kindle-like thing - without amazon