Java 更新hibernate org.hibernate.hql.internal.ast.QuerySyntaxException中的表时

Java 更新hibernate org.hibernate.hql.internal.ast.QuerySyntaxException中的表时,java,mysql,hibernate,Java,Mysql,Hibernate,我尝试上传.xls文件。我从该文件中获取值,然后更新表 我试图用一个条件更新一个表,该条件在两个表中是唯一的。 在更新时,我得到了以下异常 "org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "set", found ','" 我将在此处显示我的逻辑代码。 Controller.java HSSFSheet worksheet = workbook.getSheetAt(0); //

我尝试上传.xls文件。我从该文件中获取值,然后更新表

我试图用一个条件更新一个表,该条件在两个表中是唯一的。 在更新时,我得到了以下异常

"org.hibernate.hql.internal.ast.QuerySyntaxException: expecting "set", found ','" 
我将在此处显示我的逻辑代码。
Controller.java

    HSSFSheet worksheet = workbook.getSheetAt(0);

//                                    int challan= this.epzdao.getChallannoplusone(req);
//                          //Reads the data in excel file until last row is encountered
                            for(int i=0;i < worksheet.getPhysicalNumberOfRows()-1;i++)
                            {
//                              //Creates an object for the Candidate  Model

//                              //Creates an object representing a single row in excel
                                HSSFRow row = worksheet.getRow(i + 1);
                                //Sets the Read data to the model class
                                String jobid = row.getCell(1).getStringCellValue();
                                String isbn = row.getCell(7).getStringCellValue();
//                              double challanno = row.getCell(40).getNumericCellValue();
                                String challannoo = row.getCell(40).getStringCellValue();
                                String taxvalue = row.getCell(48).getStringCellValue();
                                String cgstratee = row.getCell(49).getStringCellValue();
                                String cgstamtt = row.getCell(50).getStringCellValue();
                                String igstratee = row.getCell(51).getStringCellValue();
                                String igstamtt = row.getCell(52).getStringCellValue();
                                String sgstratee = row.getCell(53).getStringCellValue();
                                String sgstamtt = row.getCell(54).getStringCellValue();
                                String Status = "Completed";

                                System.out.println("=============================================");
                                System.out.println("The Jobdocketid value is:"+jobid);
                                System.out.println("The ISBN Value is:"+isbn);
                                System.out.println("The challannoo Value is:"+challannoo);
                                System.out.println("The taxvalue Value is:"+taxvalue);
                                System.out.println("The cgstratee Value is:"+cgstratee);
                                System.out.println("The cgstamtt Value is:"+cgstamtt);
                                System.out.println("The igstratee Value is:"+igstratee);
                                System.out.println("The igstamtt Value is:"+igstamtt);
                                System.out.println("The sgstratee Value is:"+sgstratee);
                                System.out.println("The sgstamtt Value is:"+sgstamtt);
                                System.out.println("The Status Value is:"+Status);
                                System.out.println("=============================================");

                                int updatedctax = this.epzdao.updatedatatax(jobid, isbn, challannoo, taxvalue, cgstratee,cgstamtt, igstratee, igstamtt, sgstratee, sgstamtt, Status);

                                if(updatedctax > 0){
                                    req.setAttribute("bodyMessageStatus", "Updated Successfully");  
                                    System.out.println("Updated Successfully!");
                                }else{
                                    req.setAttribute("bodyMessageError","Updation Failed Please try Again");
                                    System.out.println("Updated Not Successfully!");
                                }
                    }  
ChallanDaoImpl.java

@Override
public int updatedatatax(String jobdocketid, String isbn, String challannoo, String taxvalue, String cgstratee, String cgstamtt, String igstratee, String igstamtt, String sgstratee, String sgstamtt, String status) {
    {   

    JobDocketStatus jobdocket = null; 
      int res = 0;
    Session session = sessionFactory.openSession();
    session.beginTransaction();     
     DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date =  new Date();
        System.out.println(dateFormat.format(date));    
        String datefrmt = dateFormat.format(date);

    try {

        Update Challan_dc p, Sales q set p.taxablevalue =:field1, p.cgstrate =:field2, p.cgstamt =:field3, p.sgstrate =:field4, p.sgstamt =:field5, p.igstrate =:field6, p.igstamt =:field7, p.status =:field10 where q.jobdocketid = p.jobDocketId and q.isbn =:field8 and p.challanno = :field9 and q.jobdocketid =:field11");                  
          qry.setParameter("field1",taxvalue);
          qry.setParameter("field2",cgstratee); 
          qry.setParameter("field3",cgstamtt);
          qry.setParameter("field4",igstratee);
          qry.setParameter("field5",igstamtt);
          qry.setParameter("field6",sgstratee);
          qry.setParameter("field7",sgstamtt);
          qry.setParameter("field8",isbn);
          qry.setParameter("field9",challannoo);
          qry.setParameter("field10",status);
          qry.setParameter("field11", jobdocketid);



        res = qry.executeUpdate();
      System.out.println("res count" + res);
      session.getTransaction().commit();
    } catch (Exception e) 
    {
        e.printStackTrace();
        //return list();
    } 
    finally 
    {
        session.close();
    }
    return res;
}

由于更新时不能在
HQL
中使用
JOIN
,因此可以使用
子查询

看看这里

您可以尝试此查询,也可以根据需要进行修改

Update Challan_dc p
SET 
p.taxablevalue =:field1, p.cgstrate =:field2, p.cgstamt =:field3, p.sgstrate =:field4, p.sgstamt =:field5, p.igstrate =:field6, p.igstamt =:field7, p.status =:field10  
where  
q.isbn =:field8  
and p.challanno = :field9  
and p.jobDocketId IN ( select q.jobdocketid from Sales q );
//OR
and p.jobDocketId = ( select q.jobdocketid from Sales q where some conditon);

我们需要基于父表和子表创建hibernate映射文件.hbm。因为对父表的更新也会导致子表的更新。

如何合并数据??使用em.merge或executeUpdate()??executeUpdate()你能更新代码吗?这样我就能帮你了
Update Challan_dc p
SET 
p.taxablevalue =:field1, p.cgstrate =:field2, p.cgstamt =:field3, p.sgstrate =:field4, p.sgstamt =:field5, p.igstrate =:field6, p.igstamt =:field7, p.status =:field10  
where  
q.isbn =:field8  
and p.challanno = :field9  
and p.jobDocketId IN ( select q.jobdocketid from Sales q );
//OR
and p.jobDocketId = ( select q.jobdocketid from Sales q where some conditon);