hibernate annotations和hbm.xml配置文件并存配置

hibernate annotations和hbm.xml配置文件并存配置
  1. <bean id="sessionFactory"  
  2.         class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">  
  3.         <property name="dataSource" ref="dataSource" />  
  4.         <property name="mappingResources">  
  5.             <list>  
  6.                 <value>/com/yese/domain/Bulletin.hbm.xml</value>  
  7.                 <value>/com/yese/domain/User.hbm.xml</value>  
  8.                 <value>/com/yese/domain/RoleProgram.hbm.xml</value>  
  9.                 <value>/com/yese/domain/Role.hbm.xml</value>  
  10.                 <value>/com/yese/domain/QuestionOption.hbm.xml</value>  
  11.                 <value>/com/yese/domain/Question.hbm.xml</value>  
  12.                 <value>/com/yese/domain/ProgramRecommend.hbm.xml</value>  
  13.                 <value>/com/yese/domain/ProgramPhase.hbm.xml</value>  
  14.                 <value>/com/yese/domain/ProgramDownloadLog.hbm.xml</value>  
  15.                 <value>/com/yese/domain/ProgramCategory.hbm.xml</value>  
  16.                 <value>/com/yese/domain/Program.hbm.xml</value>  
  17.                 <value>/com/yese/domain/Mail.hbm.xml</value>  
  18.                 <value>/com/yese/domain/ArticleCategory.hbm.xml</value>  
  19.             </list>  
  20.         </property>  
  21.           
  22.         <property name="annotatedClasses">  
  23.             <list>  
  24.                 <value>com.yese.domain.Article</value>  
  25.             </list>  
  26.         </property>  
  27.   
  28.         <property name="hibernateProperties">  
  29.             <props>  
  30.                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>  
  31.                 <prop key="hibernate.show_sql">true</prop>  
  32.                 <prop key="hibernate.query.substitutions">true 1false 0</prop>  
  33.                 <prop key="hibernate.autoReconnect">true</prop>  
  34.                 <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>  
  35.                 <prop key="hibernate.cache.use_query_cache">true</prop>  
  36.                 <prop key="hibernate.cache.use_second_level_cache">true</prop>  
  37.                 <prop key="hibernate.cache.provider_class">com.yese.cache.memcached.MemcachedCacheProvider</prop>  
  38.                   
  39.                 <prop key="hibernate.search.default.directory_provider">org.hibernate.search.store.FSDirectoryProvider</prop>  
  40.                 <prop key="hibernate.search.default.indexBase">c:/indexes</prop>  
  41.                 <!--   
  42.                 <prop key="hibernate.search.analyzer"></prop>  
  43.                   -->  
  44.                   
  45.                 <prop key="memcached.servers">192.168.1.32:12000</prop>  
  46.                 <prop key="memcached.failover">true</prop>  
  47.                 <prop key="memcached.initConn">10</prop>  
  48.                 <prop key="memcached.minConn">10</prop>  
  49.                 <prop key="memcached.maxConn">1000</prop>  
  50.                 <prop key="memcached.maintSleep">30</prop>  
  51.                 <prop key="memcached.nagle">false</prop>  
  52.                 <prop key="memcached.socketTO">3000</prop>  
  53.                 <prop key="memcached.aliveCheck">true</prop>  
  54.                   
  55.                 <!-- memcached -->  
  56.                 <!--   
  57.                 <prop key="memcached.org.hibernate.cache.StandardQueryCache">30s</prop>  
  58.                 <prop key="memcached.org.hibernate.cache.UpdateTimestampsCache">30s</prop>  
  59.                 <prop key="memcached.com.yese.domain.Article">30s</prop>  
  60.                 <prop key="memcached.com.yese.domain.Mail">30s</prop>  
  61.                  -->  
  62.             </props>  
  63.         </property>  
  64.     </bean> 


<property name="mappingResources">指定映射文件
<property name="annotatedClasses">指定annotation类
<property name="mappingDirectoryLocations">
       <list>
            <value>classpath:/com/duxiu/document</value>
       </list>
</property>指定映射文件夹

你可能感兴趣的:(hibernate annotations和hbm.xml配置文件并存配置)