我想用HQL进行测试,但是映射表有注释。Hibernate配置文件位于/WEB/spring ws.xml :::>中。
<!-- 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
我觉得我的英语水平太低了。谢谢
发布于 2015-09-22 13:55:15
确保您的hibernate.cfg.xml在src/main/resources中,如果文件不在那里,您需要指定正确的位置,所以将其放在这个文件夹中,您的问题就会得到解决。
注意,我们不必显式地提到映射或配置或属性文件,因为hibernate运行时会查找默认文件名,比如Hibernate。cfg.xml或hibernate.properties,在类路径中加载它们。如果我们有一个非默认的名称,请确保将其作为一个类似于参数的配置(“my-hibcfg.xml”)传递。
https://stackoverflow.com/questions/32698933
复制相似问题