The integration of Hibernate and Spring

Source: Internet
Author: User

Just learned the integration of Hibernate and spring, and now it's time to summarize.

To implement a function as an example, share the whole process with you.

What you need to do: build a person class that includes name,sex,age,birthaday four properties that we want to implement to add a person object to the database through Hibernate and spring.

Here's the whole process:

1. Create a new Java project and rewind the package (including SPRING,HIBERNATE,JDBC,C3P0, etc.)

2. Add the external C3P0 connection pool configuration file

3. Preparation of entity classes and their mapping files and hibernate configuration files

Configuration file Preparation for 4.spring

The spring configuration file is roughly divided into 4 parts: injection of the connection pool data source, session factory injection, bean injection, declaration of the transaction

5. Background code

DAO and Service Interface code:

DAO and Service implementation class code

Test code

The integration of Hibernate and Spring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.