ITeye博客

spring 扫描 hibernate 注解:packagesToScan

submaze · 2014-08-02 15:37 · SSH · 企业架构 · Markdown

这几天在搭建一个新架构,引用了spring 2.5.6中新加的特性,就是自动扫描Class的hibernate映射文件。 我的class都在com.pplus.model这个包里,注意 配置参数 org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean



<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="namingStrategy">
           <bean class="org.hibernate.cfg.ImprovedNamingStrategy"/>
        </property>
        <property name="hibernateProperties">
            <value>
                hibernate.dialect=${hibernate.dialect}
                hibernate.query.substitutions=true 'Y', false 'N'
                hibernate.cache.use_second_level_cache=true
                hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider
            </value>
            <!-- Turn batching off for better error messages under PostgreSQL -->
            <!-- hibernate.jdbc.batch_size=0 -->
        </property>
        <property name="packagesToScan">
            <list>
              <value>com.pplus.*</value>  <!--若写成com.pplus.model.* 则映射不到,还没有来得及看源代码 -->
            </list>
         </property>
    </bean>


评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。