首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹簧、Cfg+Hibernate、Cfg和Anotations

弹簧、Cfg+Hibernate、Cfg和Anotations
EN

Stack Overflow用户
提问于 2015-09-21 15:23:47
回答 1查看 110关注 0票数 0

我想用HQL进行测试,但是映射表有注释。Hibernate配置文件位于/WEB/spring ws.xml :::>中。

代码语言:javascript
复制
<!-- Activate transaction declarations with annotations -->
<tx:annotation-driven transaction-manager="transactionManager"/>

<!-- Property files application uses -->
<bean id="propertyConfigurer"
        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>classpath:jdbc.properties</value>
        </list>
    </property>
</bean>

<!-- JNDI DataSource -->
<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="${dataSource.jndiName}" />
    <property name="lookupOnStartup" value="false"/>
    <property name="cache" value="true"/>
    <property name="proxyInterface" value="javax.sql.DataSource"/>
</bean>

<!-- Hibernate SessionFactory -->
<bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
    <property name="packagesToScan">
        <list>
            <value>es.sergas.rprof.profesional.domain</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.default_schema">${hibernate.default_schema}</prop>
            <prop key="hibernate.dialect">${hibernate.dialect}</prop>
            <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
            <prop key="hibernate.generate_statistics">true</prop>
            <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
            <prop key="hibernate.cache.use_second_level_cache">${hibernate.cache.use_second_level_cache}</prop>
        </props>
    </property>
</bean>

<!-- Transaction manager for Hibernate SessionFactory -->
<bean id="transactionManager"
        class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
</bean>

当我运行一个列表时,我知道您没有找到hibernate cfg: hibernate.cfg.xml找不到

我只想列出一个带有注释的映射类,但是HQL

我觉得我的英语水平太低了。谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-09-22 13:55:15

确保您的hibernate.cfg.xmlsrc/main/resources中,如果文件不在那里,您需要指定正确的位置,所以将其放在这个文件夹中,您的问题就会得到解决。

注意,我们不必显式地提到映射或配置或属性文件,因为hibernate运行时会查找默认文件名,比如Hibernate。cfg.xml或hibernate.properties,在类路径中加载它们。如果我们有一个非默认的名称,请确保将其作为一个类似于参数的配置(“my-hibcfg.xml”)传递。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32698933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档