躺在沙滩上的小猪

快乐的每一天

配置spring,通过Annotations生成SessionFactory

AnnotationSessionFactoryBean 继承LocalSessionFactoryBean

今天用到,查了一下refrence,顺便把它贴出来:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
        "http://www.springframework.org/dtd/spring-beans.dtd"
>
<beans>
    
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        
<property name="location">
            
<value>classpath:jdbc.properties</value>
        
</property>
    
</bean>

    
<bean id="c3p0DataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
          destroy-method
="close">
        
<property name="driverClass">
            
<value>${db.driverClass}</value>
        
</property>
        
<property name="jdbcUrl">
            
<value>${db.url}</value>
        
</property>
        
<property name="properties">
            
<props>
                
<prop key="c3p0.acquire_increment">5</prop>
                
<prop key="c3p0.idle_test_period">100</prop>
                
<prop key="c3p0.max_size">100</prop>
                
<prop key="c3p0.max_statements">0</prop>
                
<prop key="c3p0.min_size">10</prop>
                
<prop key="user">${db.user}</prop>
                
<prop key="password">${db.pass}</prop>
            
</props>
        
</property>
    
</bean>

    
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        
<property name="hibernateProperties">
            
<props>
                
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
                
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            
</props>
        
</property>
        
<property name="dataSource" ref="c3p0DataSource"/>
        
<property name="annotatedClasses" value="martin.dwr.demo.model.User"/>
    
</bean>

    
<bean id="userDao" class="martin.dwr.demo.dao.hibernate.HibernateUserDAO">
        
<property name="sessionFactory" ref="sessionFactory"/>
    
</bean>
</beans>

posted on 2006-03-15 22:09 martin xus 阅读(1220) 评论(0)  编辑  收藏