Hibernate communication and Spring IoC Management

Source: Internet
Author: User

When hibernate was used independently, Hibernate had its own configuration file hibernate. cfg. XML, which is now under spring management. The bean is merged into applicationcontext. xml.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver"></property><property name="url" value="jdbc:mysql://localhost:3306/sms"></property><property name="username" value="root"></property><property name="password" value="123"></property></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"><property name="dataSource"><ref bean="dataSource" /></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop></props></property><property name="mappingResources"><list><value>com/sms/database/data/TSmsUser.hbm.xml</value></list></property></bean>

Compare the previous configurations of Hibernate

<?xml version='1.0' encoding='utf-8'?><!DOCTYPE hibernate-configuration PUBLIC        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

One point is that the hibernate configuration is in

<Sessionfactory>

</Sessionfactory>

In this label, that is to say, the hibernate configuration serves sessionfactory. Property name = "?? "The value of this question mark must refer to some configuration items.

The following is a possible configuration item after the context prompt in spring,

In this way, Hibernate and spring are integrated.

To be continued ~~~

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.