天天看点

hibernate4与spring4整合时,映射文件和注解

<--注解方式 -->
           
 <bean id="factory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource" ref="myDataSource"></property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.SQLServerDialect
    </prop>
   </props>
  </property>
  <property name="annotatedClasses">
   <list>
    <value>com.yin.hibernate.GuestBook</value>
   </list>
  </property>
 </bean>
           
<--映射文件方式-->
           
<bean id="factory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="dataSource" ref="myDataSource"></property>
  <property name="hibernateProperties">
   <props>
    <prop key="hibernate.dialect">
     org.hibernate.dialect.SQLServerDialect
    </prop>
   </props>
  </property>
  <property name="mappingResources">
   <list>
    <value>com/yin/hibernate/GuestBook.hbm.xml</value>
   </list>
  </property>
 </bean>
           

标红部分为区别。