hibernate annotations和hbm.xml配置文件并存配置
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="current_session_context_class">thread</prop>
<!--
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
-->
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">none</prop>
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
<property name="packagesToScan" value="com.*.dao.pojo.*" />
<property name="mappingResources">
<list>
<!--
<value>com/*/*/User.hbm.xml</value>
-->
</list>
</property>
</bean>
本文详细介绍了如何使用Spring框架下的AnnotationSessionFactoryBean来配置Hibernate,包括数据源、方言设置、缓存配置等,并展示了如何同时支持注解和hbm.xml映射文件。
133

被折叠的 条评论
为什么被折叠?



