从XML里面读取出几个ID,我将结果拼接成 '1012','1013','1014' 这种格式,
List tbalist = session.createQuery("from TbActual tba where tba.relevantID in(" + allId + ")").list();
这句代码出来问题 ,请各位大虾帮看看,并说明下原因
谢谢了

解决方案 »

  1.   

    把语句输出下 你的那个属性是什么类型的 是VARCHAR么? 还是NUMBER? 
      

  2.   

    session.createQuery("from TbActual tba where tba.relevantID in(" + allId + ")").list(); 你可以把语句输出下么 不过既然你说是int型呢 那么
    "'1012','1013','1014'"是不是应该改成
    "1012,1013,1014"
      

  3.   


    Sqlserver支持这种模式的,可以用String类型的查int,但是不可以用int的查String.
      

  4.   


    HIBERNATE最后将之转义为SQL语句我自己解决掉了。
      

  5.   

    DetachedCriteria criteria = DetachedCriteria.forClass(Entity.class);

    criteria.add(Restrictions.in(params, array));
      

  6.   


    你的查询条件在那放着呢 不用IN也是OR 还有别的招么?
      

  7.   

    批量的,不知道你要的是不是这个:public static void readFileWriteBack(String fileName, Connection con)
    throws Exception {
    String s = "";
    File f = new File(fileName);
    if (!f.exists()) {
    throw new Exception("file doesn't exist....");
    }
    BufferedReader br = null;
    PreparedStatement pstmt = null;
    try {
    br = new BufferedReader(new InputStreamReader(
    new FileInputStream(f)));
    String sql = "insert into tbl_report(a,b,c,d)"
    + "values(?,?,?,'2009-12-07')";
    pstmt = con.prepareStatement(sql);
    // 循环外部准备好prepareStatement;
    while ((s = br.readLine()) != null) {
    if (s.indexOf("合计") > 0) {
    continue;
    }
    String[] c = s.split("\t");
    printArray(c);
    if (c.length == 3) {
    // 加入批量参数
    pstmt.setString(1, c[0]);
    pstmt.setString(2, c[1]);
    pstmt.setString(3, c[2]);
    pstmt.addBatch();
    }
    }
    // 一次执行。
    pstmt.executeBatch();
    System.out.println("file write back finished");
    } catch (Exception e) {
    throw e;
    } finally {
    try {
    if (pstmt != null) {
    pstmt.close();
    }
    br.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }