我得到例外java.lang.Exception: Named query not known: FileVersionStatusByMeterid; nested exception is org.hibernate.MappingException: Named query not known: FileVersionStatusByMeterid
我的配置文件是:
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="dataSource" ref="poolDataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.generate_statistics">true</prop>
</props>
</property>
</bean>
并且我的属性类具有命名查询的缺陷
public static final String FileVersionStatusByMeterid_Name = "FileVersionStatusByMeterid";
public static final String FileVersionStatusByMeterid_Query = "from ACSRateFileVersionStatus where MeterID =:meterID and FileType= :fileType";
我的bean类是
import com.duncansolutions.databus.external.constant.NamedQueryStatements;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@Entity
@Table(name = "ACS_Rate_File_Version_Status")
@NamedQueries({
@NamedQuery(name = NamedQueryStatements.FileVersionStatusByMeterid_Name, query =NamedQueryStatements.FileVersionStatusByMeterid_Query)})
public class ACSRateFileVersionStatus implements java.io.Serializable {
任何人都可以告诉我在哪里出错以避免异常吗?