Spring中使用Hibernate3的Annotation
来源:互联网 发布:战舰世界大和转炮数据 编辑:程序博客网 时间:2024/05/17 05:17
Hibernate3 Annotation的SessionFactory创建需要有两个地方与用mapping resource的方式不同:
Configuration需要使用新的org.hibernate.cfg.AnnotationConfiguration
需要使用新的mappingClass元素而不是使用mappingResource
org.springframework.orm.hibernate3.LocalSessionFactoryBean 对此的支持是configurationClass属性及configLocation属性,也就是分别设置configurationClass和hibernate.cfg.xml的位置(mappingClass在配置文件中设置)。
设置的例子如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean是专门针对这个问题的解决办法,只需要使用这个类做SessionFactory,则只需要直接设置annotatedClasses属性即可。设置的例子如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>test.package.Foo</value>
<value>test.package.Bar</value>
</list>
</property>
</bean>
Configuration需要使用新的org.hibernate.cfg.AnnotationConfiguration
需要使用新的mappingClass元素而不是使用mappingResource
org.springframework.orm.hibernate3.LocalSessionFactoryBean 对此的支持是configurationClass属性及configLocation属性,也就是分别设置configurationClass和hibernate.cfg.xml的位置(mappingClass在配置文件中设置)。
设置的例子如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean是专门针对这个问题的解决办法,只需要使用这个类做SessionFactory,则只需要直接设置annotatedClasses属性即可。设置的例子如下:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
<property name="annotatedClasses">
<list>
<value>test.package.Foo</value>
<value>test.package.Bar</value>
</list>
</property>
</bean>
- Spring中使用Hibernate3的Annotation
- Spring中使用Hibernate3的Annotation
- hibernate3 Annotation的使用
- hibernate3.5和spring结合使用annotation时onetomany的bug
- spring中AOP的Annotation使用流程
- hibernate3 Annotation中使用oracle seq生成主键值
- Spring中使用annotation注入
- Spring中使用annotation注入
- Spring中使用annotation注入
- Spring中使用annotation注入
- Spring中使用annotation注入
- 使用annotation开发hibernate3程序
- 解决 spring mvc 3.0 结合 hibernate3.2 使用<tx:annotation-driven>声明式事务无法提交的问题
- 解决 spring mvc 3.0 结合 hibernate3.2 使用<tx:annotation-driven>声明式事务无法提交的问题
- 解决 spring mvc 3.0 结合 hibernate3.2 使用<tx:annotation-driven>声明式事务无法提交的问题
- Hibernate3中DetachedCriteria的使用
- Hibernate3中DetachedCriteria的使用
- Hibernate3中DetachedCriteria的使用
- Android模拟器安装apk文件
- 详解内核驱动操作GPIO引脚API函数
- Safe Browsing API
- 关于html5的webworker的简单示例
- ASP.NET导出Excel并将Excel进程关闭 (根据进程ID)
- Spring中使用Hibernate3的Annotation
- ios用UIWebView打开txt乱码的解决方案
- 关于Ubuntu下apt的一些用法及和yum的比较
- JavaFX2.0 UI控件教程 之 控件概览
- wince的驱动模型
- 活用Linux操作系统的后台任务
- listView中多个listItem布局时,convertView缓存及使用
- 如何将海康高清摄像机转成opencv可以处理的格式?
- 我的SHELL笔记