Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
hibernate中关于java.lang.arithmetricException的错误_Java_Sql Server_Hibernate - Fatal编程技术网

hibernate中关于java.lang.arithmetricException的错误

hibernate中关于java.lang.arithmetricException的错误,java,sql-server,hibernate,Java,Sql Server,Hibernate,我的代码中出现错误,我找不到原因。异常日志为: HH000315:异常执行批处理[java.lang.arithmetricException:/by zero],SQL:update-TVSENSORINFO-set-SENSORTYPE=?,TEMP=?,REPORTTIMESPAN=?,SENSORSTATE=?,V=?,AddTime=?,UpdateTime=?,LOCATIONID=?,RSSI=?,VISHIS=?其中SENSORNUM= 我正在对MSSQL中的一个表进行更新。代码

我的代码中出现错误,我找不到原因。异常日志为:

HH000315:异常执行批处理[java.lang.arithmetricException:/by zero],SQL:update-TVSENSORINFO-set-SENSORTYPE=?,TEMP=?,REPORTTIMESPAN=?,SENSORSTATE=?,V=?,AddTime=?,UpdateTime=?,LOCATIONID=?,RSSI=?,VISHIS=?其中SENSORNUM=

我正在对MSSQL中的一个表进行更新。代码是:

    public void saveOrUpdate(Collection<?> collections) {
        Session session = sessionFactory.openSession();
        Transaction tran = session.beginTransaction();
        try {
            Callable<Boolean> saveOrUpdateCallable = new Callable<Boolean>() {
                @Override
                public Boolean call() {
                    try {
                        for (var item : collections){
                            session.saveOrUpdate(item);
                        }
                        tran.commit();
                        return true;
                    } catch (Exception e) {
                        LogManager.writeError("HibernateUtil, saveOrUpdateCallable!" + " Size of collections:" + collections.size(), e);
                        tran.rollback();
                        return false;
                    }
                }
            };
            TimeoutUtil.<Boolean>process(saveOrUpdateCallable, 20, "HibernateUtil-saveOrUpdate");
        } catch (Exception e) {
            LogManager.writeError("Exception at HibernateUtil, saveOrUpdate!" + " Size of collections:" + collections.size(), e);
            tran.rollback();
        } finally {
            session.clear();
            session.close();
        }
    }
public void保存或更新(集合){
Session Session=sessionFactory.openSession();
事务传输=session.beginTransaction();
试一试{
Callable saveOrUpdateCallable=新可调用(){
@凌驾
公共布尔调用(){
试一试{
用于(变量项:集合){
会话.保存或更新(项目);
}
trans.commit();
返回true;
}捕获(例外e){
LogManager.writeError(“HibernateUtil,saveOrUpdateCallable!”+“集合大小:”+collections.Size(),e);
事务回滚();
返回false;
}
}
};
进程(saveOrUpdateCallable,20,“HibernateUtil saveOrUpdate”);
}捕获(例外e){
LogManager.writeError(“HibernateUtil异常,saveOrUpdate!”+“集合大小:”+collections.Size(),e);
事务回滚();
}最后{
session.clear();
session.close();
}
}

谢谢。

您不能与其他线程共享会话。您必须为每个线程创建一个会话。

谢谢,我将尝试移动会话。