天天看點

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>
           

标紅部分為差別。