教育网研究 根据一级id显示下面所有级id

本文介绍了一种使用Java Hibernate技术递归查询数据库中特定层级ID的方法,并展示了如何处理查询结果来构建新的查询条件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 String thirdid=dbo.nextID("7");   // thirdid为11,12,13,14,34,多了一个逗号,下面蓝色的部分是进行处理
 String hqldown="from Source_inf where in ("+thirdid.substring(0,(thirdid.length()-1))+") order by neworders";

DBOperator的一个方法如下
  /**
   * 根据source_type的id判断是下级的id ,现在收录第三级的id
   *
   */
  public String nextID(String id)
  {  
  String myid=id+",";
//  Source_type
//   hql="from Source_type where id="+level;
  String hql="from Source_type where levels="+id;
 // this.setLength(20);
  List secondidL=this.findSQLHibernate(hql, 1);
  Source_type  mytype2=new Source_type();
  Source_type  mytype3=new Source_type();
  for(int q=0;q<secondidL.size();q++)
   {
   mytype2=(Source_type)secondidL.get(q);
  int thisid=mytype2.getId();
  String hql2="from Source_type where levels="+thisid;
  List thirdidL=this.findSQLHibernate(hql2, 1);
   for(int a=0;a<thirdidL.size();a++)
    { mytype3=(Source_type)thirdidL.get(a);
       int thirdid=mytype3.getId();
       myid+=thirdid;
       myid+=",";

    }
   }
 
  return myid;
 
  }

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值