<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>WEB-INF/resources/core/base/hbm</value>
<value>WEB-INF/resources/core/user/hbm</value>
<value>WEB-INF/resources/detect/resource/hbm</value>
</list>
</property>
<property name="hibernateProperties">
<props> <prop key="hibernate.show_sql">true</prop>
<!--prop key="hibernate.hbm2ddl.auto">update</prop-->
</props>
</property>
</bean> <bean id="sessionFactoryOper"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSourceOper" />
</property>
<property name="mappingDirectoryLocations">
<list>
<value>WEB-INF/resources/modules/solve/hbm</value>
</list>
</property>
<property name="hibernateProperties">
<props> <prop key="hibernate.show_sql">true</prop>
<!--prop key="hibernate.hbm2ddl.auto">update</prop-->
</props>
</property>
</bean>
CheckObject.hbm.xml  是在 WEB-INF/resources/modules/solve/hbm
报出错误找不到对象
 [http-80-Processor25] ActionExceptionHandler.logException(145) | org.springframework.orm.hibernate3.HibernateQueryException: CheckObject is not mapped [from CheckObject a order by a.checkobjectId]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: CheckObject is not mapped [from CheckObject a order by a.checkobjectId]
Caused by: org.hibernate.hql.ast.QuerySyntaxException: CheckObject is not mapped [from CheckObject a order by a.checkobjectId]
        at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
        at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
        at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
        at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:265)

解决方案 »

  1.   

    上面的<bean id="sessionFactory"
            class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    加载没有问题兄弟我急 啊!!
      

  2.   

    CheckObject.hbm.xml  没加到xxxhibernate.cfg.xml?顺便问下,
    <property name="dataSource">
                <ref bean="dataSource" />
    <property name="dataSource">
                <ref bean="dataSourceOper" />都是name="dataSource",那它如何决定用下面的哪个bean对应的class,随机?
      

  3.   

    Spring 的datasource neme是这样配置的
      

  4.   

    配置应该是没有问题的
    你都没有加载CheckObject.hbm.xml 应该这样子的啊
    <list>
                    <value>WEB-INF/resources/modules/solve/hbm/CheckObject.hbm.xml</value>
                </list>
      

  5.   

    我是这样的 
     <property name="mappingDirectoryLocations">
                <list>
                    <value>WEB-INF/resources/modules/solve/hbm</value>
                </list>
            </property>mappingDirectoryLocations 表示是文件夹。
    5楼的说法我试过,还是不行。。
      

  6.   

    从你的报错看 就是没有加载CheckObject.hbm.xml 这个文件 或者你的目录下面根本就没有这个文件 检查一下
      

  7.   

    我把这个<value>WEB-INF/resources/modules/solve/hbm </value>  放在上面的sessionFactory 中就不会出现这样的错误。的确很郁闷
      

  8.   

    那说明你上面的哪个sessionFactory 是需要CheckObject.hbm.xml 这个文件
      

  9.   


    不大对把,
    CheckObject.hbm.xml明显是对应一个表,只要在〈list〉下面即可,主要是在找hibernate要对象时它知道在哪里找给你,既然配的2个池,那应该并不需要指定放哪,只要在里头就行,
    倒有可能是由spring加载hibernate时,第2个池没加载成功,你干脆把前头3个<value>WEB-INF/resources/core/base/hbm</value>
                    <value>WEB-INF/resources/core/user/hbm</value>
                    <value>WEB-INF/resources/detect/resource/hbm</value>
    都放到第2个池,看异常有没有变到指向前面3个,同时保证测试调用时这3个其中一个在CheckObject前头调用,
      

  10.   

    from CheckObject a order by a.checkobjectId
    从这句来看lz是做了查询,但是不知道lz在程序里是取的哪个SessionFactory是第一个,还是第二个?要用的第一个报这个错误不奇怪,要是用的第二个报这个错误就奇怪了。不知道lz看明白我的意思没有
      

  11.   

     10 楼的不大对把, 
    CheckObject.hbm.xml明显是对应一个表,只要在〈list〉下面即可,主要是在找hibernate要对象时它知道在哪里找给你,既然配的2个池,那应该并不需要指定放哪,只要在里头就行, 
    倒有可能是由spring加载hibernate时,第2个池没加载成功, 你干脆把前头3个 <value>WEB-INF/resources/core/base/hbm </value> 
                    <value>WEB-INF/resources/core/user/hbm </value> 
                    <value>WEB-INF/resources/detect/resource/hbm </value> 
    都放到第2个池,看异常有没有变到指向前面3个,同时保证测试调用时这3个其中一个在CheckObject前头调用,
    这样我测试过。我如果按照你的做法,我的另外的一个数据库中就没有上面的表。所有还是报错的。。
    在tomacat启动的时候好像是加载了下面的SessionFactory
    我把路径改了就报错-找不到文件
      

  12.   


    这位大哥说的小弟不是很理解
    我好像没有取。所有的DAO配置
    <bean id="dao"
    class="com.appsafe.core.base.dao.hibernate.BaseDaoHibernate"
    autowire="byName" />
    都是byName的,谢谢指教
      

  13.   

    这些写法如果check后都没有问题了!
    那就检查下 classese目录下面有这个文件!