log 如下:
2006/06/20 11:46:52 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/57) -Entering method 'getData' of class [jp.co.nec.necst.ebiz.community.service.GoodsListServiceImpl]
2006/06/20 11:46:52 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/57) -Entering method 'getData' of class [jp.co.nec.necst.ebiz.community.proc.GoodsListProcImpl]
2006/06/20 11:46:52 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/57) -Entering method 'loadGoods' of class [jp.co.nec.necst.ebiz.community.dao.GoodsInfoDaoImpl]
Hibernate: select tgood0_.ID as ID0_, tgood0_.SHOP_ID as SHOP2_0_, tgood0_.GOODS_ID as GOODS3_0_, tgood0_.GOODS_NAME as GOODS4_0_, tgood0_.CATEGORY_ID as CATEGORY5_0_, tgood0_.PRICE as PRICE0_, tgood0_.STD_PRICE as STD7_0_, tgood0_.IMAGE_FILE as IMAGE8_0_, tgood0_.S_COMMENTS as S9_0_, tgood0_.L_COMMENTS as L10_0_, tgood0_.REGIST_DATE as REGIST11_0_, tgood0_.UPDATE_DATE as UPDATE12_0_, tgood0_.DELETE_DATE as DELETE13_0_, tgood0_.MODIFIED_USER_ID as MODIFIED14_0_ from T_GOODS tgood0_ where tgood0_.CATEGORY_ID=?
2006/06/20 11:47:45 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/60) -Exiting method 'loadGoods' of class [jp.co.nec.necst.ebiz.community.dao.GoodsInfoDaoImpl]
2006/06/20 11:48:23 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/60) -Exiting method 'getData' of class [jp.co.nec.necst.ebiz.community.proc.GoodsListProcImpl]
2006/06/20 11:48:23 DEBUG [http-8080-1] (SimpleTraceInterceptor.java/60) -Exiting method 'getData' of class [jp.co.nec.necst.ebiz.community.service.GoodsListServiceImpl]

解决方案 »

  1.   

    TGood.hbm.xml如下:<?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
        
    <hibernate-mapping>
    <!-- 
        Created by the Middlegen Hibernate plugin 2.2    http://boss.bekk.no/boss/middlegen/
        http://www.hibernate.org/
    --><class 
        name="jp.co.nec.necst.ebiz.community.entity.TGood" 
        table="T_GOODS"
        lazy="false"
        dynamic-update="true"
    >
        <meta attribute="implement-equals" inherit="false">true</meta>    <id
            name="id"
            type="java.lang.String"
            column="ID"
        >
        
            <generator class="assigned" />
        </id>    <property
            name="shopId"
            type="java.lang.String"
            column="SHOP_ID"
            length="5"
        />
        <property
            name="goodsId"
            type="java.lang.String"
            column="GOODS_ID"
            length="20"
        />
        <property
            name="goodsName"
            type="java.lang.String"
            column="GOODS_NAME"
            length="50"
        />
        <property
            name="categoryId"
            type="java.lang.String"
            column="CATEGORY_ID"
            length="20"
        />
        <property
            name="price"
            type="java.lang.Integer"
            column="PRICE"
            length="7"
        />
        <property
            name="stdPrice"
            type="java.lang.Integer"
            column="STD_PRICE"
            length="7"
        />
        <property
            name="imageFile"
            type="java.lang.String"
            column="IMAGE_FILE"
            length="100"
        />
        <property
            name="SComments"
            type="java.lang.String"
            column="S_COMMENTS"
            length="200"
        />
        <property
            name="LComments"
            type="java.lang.String"
            column="L_COMMENTS"
            length="1000"
        />
        <property
            name="registDate"
            type="java.sql.Timestamp"
            column="REGIST_DATE"
            length="7"
        />
        <property
            name="updateDate"
            type="java.sql.Timestamp"
            column="UPDATE_DATE"
            length="7"
        />
        <property
            name="deleteDate"
            type="java.sql.Timestamp"
            column="DELETE_DATE"
            length="7"
        />
        <property
            name="modifiedUserId"
            type="java.lang.String"
            column="MODIFIED_USER_ID"
            length="12"
        />    <!-- Associations -->
      </class>
    </hibernate-mapping>
      

  2.   

    在log4j.properties 文件里加上
    log4j.logger.org.hibernate.type=debug看看输出的sql及绑定的参数strCategoryId是否正常。
      

  3.   

    to Saro(这也不是江水,这是二十年流不尽的英雄血。):log4j.logger.org.hibernate.type=debug请问在log4j.xml 里面怎么写?
      

  4.   

    log 出来了:2006/06/20 21:03:21 DEBUG [http-8080-1] (ErrorCounter.java/68) -throwQueryException() : no errors
    2006/06/20 21:03:21 DEBUG [http-8080-1] (QueryTranslatorImpl.java/206) -HQL: select gi.goodsName,gi.price,gi.imageFile,gi.SComments,gi.LComments,gi.deleteDate from jp.co.nec.necst.ebiz.community.entity.TGood gi,jp.co.nec.necst.ebiz.community.entity.TGoodsCategory gc  where  gi.categoryId= ?  and gi.shopId = gc.shopId and gi.categoryId = gc.categoryId
    2006/06/20 21:03:21 DEBUG [http-8080-1] (QueryTranslatorImpl.java/207) -SQL: select tgood0_.GOODS_NAME as col_0_0_, tgood0_.PRICE as col_1_0_, tgood0_.IMAGE_FILE as col_2_0_, tgood0_.S_COMMENTS as col_3_0_, tgood0_.L_COMMENTS as col_4_0_, tgood0_.DELETE_DATE as col_5_0_ from T_GOODS tgood0_, T_GOODS_CATEGORY tgoodscate1_ where tgood0_.CATEGORY_ID=? and tgood0_.SHOP_ID=tgoodscate1_.SHOP_ID and tgood0_.CATEGORY_ID=tgoodscate1_.CATEGORY_ID
    2006/06/20 21:03:21 DEBUG [http-8080-1] (ErrorCounter.java/68) -throwQueryException() : no errors
    2006/06/20 21:03:21 DEBUG [http-8080-1] (HQLQueryPlan.java/219) -HQL param location recognition took 20 mills (select gi.goodsName,gi.price,gi.imageFile,gi.SComments,gi.LComments,gi.deleteDate from jp.co.nec.necst.ebiz.community.entity.TGood gi,jp.co.nec.necst.ebiz.community.entity.TGoodsCategory gc  where  gi.categoryId= ?  and gi.shopId = gc.shopId and gi.categoryId = gc.categoryId)
    2006/06/20 21:03:21 DEBUG [http-8080-1] (QueryPlanCache.java/75) -located HQL query plan in cache (select gi.goodsName,gi.price,gi.imageFile,gi.SComments,gi.LComments,gi.deleteDate from jp.co.nec.necst.ebiz.community.entity.TGood gi,jp.co.nec.necst.ebiz.community.entity.TGoodsCategory gc  where  gi.categoryId= ?  and gi.shopId = gc.shopId and gi.categoryId = gc.categoryId)
    2006/06/20 21:03:21 DEBUG [http-8080-1] (HQLQueryPlan.java/148) -find: select gi.goodsName,gi.price,gi.imageFile,gi.SComments,gi.LComments,gi.deleteDate from jp.co.nec.necst.ebiz.community.entity.TGood gi,jp.co.nec.necst.ebiz.community.entity.TGoodsCategory gc  where  gi.categoryId= ?  and gi.shopId = gc.shopId and gi.categoryId = gc.categoryId
    2006/06/20 21:03:21 DEBUG [http-8080-1] (QueryParameters.java/256) -parameters: [001]
    2006/06/20 21:03:21 DEBUG [http-8080-1] (QueryParameters.java/262) -named parameters: {}
    2006/06/20 21:03:21 DEBUG [http-8080-1] (AbstractBatcher.java/311) -about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    2006/06/20 21:03:21 DEBUG [http-8080-1] (ConnectionManager.java/415) -opening JDBC connection
    2006/06/20 21:03:21 DEBUG [http-8080-1] (AbstractBatcher.java/346) -select tgood0_.GOODS_NAME as col_0_0_, tgood0_.PRICE as col_1_0_, tgood0_.IMAGE_FILE as col_2_0_, tgood0_.S_COMMENTS as col_3_0_, tgood0_.L_COMMENTS as col_4_0_, tgood0_.DELETE_DATE as col_5_0_ from T_GOODS tgood0_, T_GOODS_CATEGORY tgoodscate1_ where tgood0_.CATEGORY_ID=? and tgood0_.SHOP_ID=tgoodscate1_.SHOP_ID and tgood0_.CATEGORY_ID=tgoodscate1_.CATEGORY_ID
    Hibernate: select tgood0_.GOODS_NAME as col_0_0_, tgood0_.PRICE as col_1_0_, tgood0_.IMAGE_FILE as col_2_0_, tgood0_.S_COMMENTS as col_3_0_, tgood0_.L_COMMENTS as col_4_0_, tgood0_.DELETE_DATE as col_5_0_ from T_GOODS tgood0_, T_GOODS_CATEGORY tgoodscate1_ where tgood0_.CATEGORY_ID=? and tgood0_.SHOP_ID=tgoodscate1_.SHOP_ID and tgood0_.CATEGORY_ID=tgoodscate1_.CATEGORY_ID
    2006/06/20 21:03:21 DEBUG [http-8080-1] (AbstractBatcher.java/424) -preparing statement
    2006/06/20 21:03:22 DEBUG [http-8080-1] (NullableType.java/80) -binding '001' to parameter: 1
    2006/06/20 21:03:22 DEBUG [http-8080-1] (AbstractBatcher.java/327) -about to open ResultSet (open ResultSets: 0, globally: 0)
    2006/06/20 21:03:22 DEBUG [http-8080-1] (Loader.java/682) -processing result set
    2006/06/20 21:03:22 DEBUG [http-8080-1] (Loader.java/709) -done processing result set (0 rows)
    2006/06/20 21:03:22 DEBUG [http-8080-1] (AbstractBatcher.java/334) -about to close ResultSet (open ResultSets: 1, globally: 1)
    2006/06/20 21:03:22 DEBUG [http-8080-1] (AbstractBatcher.java/319) -about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
    2006/06/20 21:03:22 DEBUG [http-8080-1] (AbstractBatcher.java/470) -closing statement
    2006/06/20 21:03:22 DEBUG [http-8080-1] (StatefulPersistenceContext.java/748) -initializing non-lazy collections
    2006/06/20 21:03:22 DEBUG [http-8080-1] (JDBCContext.java/217) -after autocommit
    2006/06/20 21:03:22 DEBUG [http-8080-1] (ConnectionManager.java/296) -transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    2006/06/20 21:03:22 DEBUG [http-8080-1] (SessionImpl.java/417) -after transaction completion
    2006/06/20 21:03:22 DEBUG [http-8080-1] (HibernateAccessor.java/393) -Eagerly flushing Hibernate session
    2006/06/20 21:03:22 DEBUG [http-8080-1] (SessionFactoryUtils.java/785) -Closing Hibernate Session
    2006/06/20 21:03:22 DEBUG [http-8080-1] (SessionImpl.java/268) -closing session
    2006/06/20 21:03:22 DEBUG [http-8080-1] (ConnectionManager.java/374) -performing cleanup
    2006/06/20 21:03:22 DEBUG [http-8080-1] (ConnectionManager.java/435) -releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
    2006/06/20 21:03:22 DEBUG [http-8080-1] (JDBCContext.java/199) -after transaction completion
    2006/06/20 21:03:22 DEBUG [http-8080-1] (ConnectionManager.java/296) -transaction completed on session with on_close connection release mode; be sure to close the session to release JDBC resources!
    2006/06/20 21:03:22 DEBUG [http-8080-1] (SessionImpl.java/417) -after transaction completion
      

  5.   

    没有数据的log:
    2006/06/20 21:03:22 DEBUG [http-8080-1] (Loader.java/709) -done processing result set (0 rows)
      

  6.   

    select tgood0_.GOODS_NAME as col_0_0_, tgood0_.PRICE as col_1_0_, tgood0_.IMAGE_FILE as col_2_0_, tgood0_.S_COMMENTS as col_3_0_, tgood0_.L_COMMENTS as col_4_0_, tgood0_.DELETE_DATE as col_5_0_ from T_GOODS tgood0_, T_GOODS_CATEGORY tgoodscate1_ where tgood0_.CATEGORY_ID=? and tgood0_.SHOP_ID=tgoodscate1_.SHOP_ID and tgood0_.CATEGORY_ID=tgoodscate1_.CATEGORY_ID2006/06/20 21:03:22 DEBUG [http-8080-1] (NullableType.java/80) -binding '001' to parameter: 1把这个sql中的?换成'001'再去执行试试吧还不行的话,只有一个可能,hibernate连的数据库和你直接执行sql的不是一个.......
    听上去很蠢,其实是很有可能的.......
      

  7.   

    to Saro(这也不是江水,这是二十年流不尽的英雄血。) :把这个sql中的?换成'001'再去执行,是有数据的。“还不行的话,只有一个可能,hibernate连的数据库和你直接执行sql的不是一个.......
    听上去很蠢,其实是很有可能的.......“你说的这种情况也确认了没有可能。http://community.csdn.net/Expert/topic/4832/4832449.xml?temp=.4470941上面的是这个的另一种情况,麻烦你去看一下,帮个忙!
      

  8.   

    该问题已解决了:
    是由于使用了Oracle DB 的 char 字段带来的问题!
      

  9.   

    使用char 字段确实会带来查询值必须以空格补全至列长的问题,但
    楼主所说的
    <<通过打开的<property name="show_sql">true</property>显示的sql文查询能查询到数据是怎么回事,我记得通过plsql dev,select ... from table where id='001' 这样的sql查询照样查不出数据的,楼主用的什么sql查询工具啊。
      

  10.   

    plsql dev6.0 可以查到的