比如我查询一个分类我是用编码规范的001是根       001001      001002等是001的子
002是根       002001      002002等是002的子但是我现在用where id=001或者00X去查询表他发出的语句把前面的00省略了不发id=001而是发id=1我数据库的ID用的是vachar类型的,JAVABEAN对应的类也是String类型的这个咋办哦我用的是MYSQL

解决方案 »

  1.   

    这个看似是没有什么不正确的,仔细检查下JSP页面有没有哪个地方写错了。
      

  2.   

    where id=001或者00X去查询表他发出的语句把前面的00省略了不发id=001而是发id=1不知楼主什么意思。把字段贴出来。
      

  3.   


    mysql> select * from t_category where id=1;
    +-----+-------+-------------+
    | id  | title | description |
    +-----+-------+-------------+
    | 001 | 电脑  | dddddddd    |
    +-----+-------+-------------+
    1 row in setmysql> select * from t_category where id=001;
    +-----+-------+-------------+
    | id  | title | description |
    +-----+-------+-------------+
    | 001 | 电脑  | dddddddd    |
    +-----+-------+-------------+
    1 row in set
    我就奇怪了,直接用数据库查询就能查询出来了。可是用程序却有问题
    public Category findCategoryById(String id) {

    return (Category) this.getHibernateTemplate().find("from Category c where c.id = "+id ).get(0);
    }
    传入的数据是id='001'
    发的语句Hibernate: select category0_.id as id0_, category0_.DESCRIPTION as DESCRIPT2_0_, category0_.title as title0_ from t_category category0_ where category0_.id=1
    数据库能查询的出来,可是程序查询的有问题我想应该是程序的问题了——!谢谢大家,我再调下。
      

  4.   

    select * from t_category where id=001;