论坛首页 入门技术论坛

Spring下使用Hibenrate annotation

浏览 5222 次
该帖已经被评为新手帖
作者 正文
   发表时间:2006-12-22  
xml 代码
  1. <bean id="sessionFactory"  
  2.     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
  3.     <property name="configurationClass">  
  4.         <value>org.hibernate.cfg.AnnotationConfiguration</value>  
  5.     </property>  
  6.     <property name="configLocation">  
  7.         <value>classpath:hibernate.cfg.xml</value>  
  8.     </property>  
  9. </bean>  


 

LocalSessionFactoryBean 中的原码注解:

 

private Class configurationClass = Configuration.class;

 /**
  * Specify the Hibernate Configuration class to use.
  * Default is "org.hibernate.cfg.Configuration"; any subclass of
  * this default Hibernate Configuration class can be specified.
  *

Can be set to "org.hibernate.cfg.AnnotationConfiguration" for
  * using Hibernate3 annotation support (initially only available as
  * alpha download separate from the main Hibernate3 distribution).
  *

Annotated packages and annotated classes can be specified via the
  * corresponding tags in "hibernate.cfg.xml" then, so this will usually
  * be combined with a "configLocation" property that points at such a
  * standard Hibernate configuration file.
  * @see #setConfigLocation
  * @see org.hibernate.cfg.Configuration
  * @see org.hibernate.cfg.AnnotationConfiguration
  */
 public void setConfigurationClass(Class configurationClass) {
  if (configurationClass == null || !Configuration.class.isAssignableFrom(configurationClass)) {
   throw new IllegalArgumentException(
     "configurationClass must be assignable to [org.hibernate.cfg.Configuration]");
  }
  this.configurationClass = configurationClass;
 }

   发表时间:2006-12-22  
学习一下
0 请登录后投票
   发表时间:2006-12-22  

dylan_cherie 写道:
xml 代码
  1. <bean id="sessionFactory"  
  2.     class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">  
  3.     <property name="configurationClass">  
  4.         <value>org.hibernate.cfg.AnnotationConfigurationvalue>  
  5.     property>  
  6.     <property name="configLocation">  
  7.         <value>classpath:hibernate.cfg.xmlvalue>  
  8.     property>  
  9. bean>  


 

LocalSessionFactoryBean 中的原码注解:

 

private Class configurationClass = Configuration.class;

 /**
  * Specify the Hibernate Configuration class to use.
  * Default is "org.hibernate.cfg.Configuration"; any subclass of
  * this default Hibernate Configuration class can be specified.
  *

Can be set to "org.hibernate.cfg.AnnotationConfiguration" for
  * using Hibernate3 annotation support (initially only available as
  * alpha download separate from the main Hibernate3 distribution).
  *

Annotated packages and annotated classes can be specified via the
  * corresponding tags in "hibernate.cfg.xml" then, so this will usually
  * be combined with a "configLocation" property that points at such a
  * standard Hibernate configuration file.
  * @see #setConfigLocation
  * @see org.hibernate.cfg.Configuration
  * @see org.hibernate.cfg.AnnotationConfiguration
  */
 public void setConfigurationClass(Class configurationClass) {
  if (configurationClass == null || !Configuration.class.isAssignableFrom(configurationClass)) {
   throw new IllegalArgumentException(
     "configurationClass must be assignable to [org.hibernate.cfg.Configuration]");
  }
  this.configurationClass = configurationClass;
 }



没弄懂lz要干什么!

0 请登录后投票
   发表时间:2006-12-24  
lz说话相当的言简意赅,我也是没有弄懂楼主的目的,楼主能否更详细点来描述一下:你要做什么,怎么做,为什么要这么做?
0 请登录后投票
   发表时间:2006-12-24  
楼主估计是想说Spring下使用Hibenrate annotation时sessionFactory的配置
0 请登录后投票
   发表时间:2006-12-30  
    不好意思没说明白,此文讲的是Hibenrate annotation在spring中使用的配置方法。
0 请登录后投票
论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics