用Hibernate3注解映射出现的异常,以下是异常消息:(from Part : 我写的HQL语句,Part 为类名),为什么为不能映射呢,启动时是没错的。请高手看看,谢谢了......2010-3-27 22:59:14 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet default threw exception
org.hibernate.hql.ast.QuerySyntaxException: Part is not mapped [from Part]框架:Struts2.0+Hibernate3.2+Spring2.5

解决方案 »

  1.   

    以下是applicationContext里的部分配置:
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    org.hibernate.dialect.SQLServerDialect
    </prop>
    </props>
    </property>
    <property name="packagesToScan">
    <list>
    <value>com.accp.entity</value>
    </list>
    </property>
    </bean>
      

  2.   

    你的映射文件肯定有误
    你的名字是否映射失败什么的要不把你的映射文件贴出来SEESEE
      

  3.   

    1.你的HQL语句中与数据库映射的类名没有写对,比如String HqlString = "from part as p where ......,这里应将part写成Part2.就是没有在spring文件中加入Part.hbm.xml路径 加进去就正确了
      

  4.   


    正解。 hibernate里面的的表名对应的是你实体类名也就是hbm。xml里面定义的类名而不是表名和其完全一致就可以了。