简体   繁体   English

如何找到我的 java object 中出现的无穷大?

[英]How to find infinity that occurs in my java object?

So I have an object of the type ProductionTest that needs to be saved via the spring framework.所以我有一个 ProductionTest 类型的 object 需要通过 spring 框架保存。 When saving it gives me an error on session.flush();保存时,它在session.flush(); which says SEVERE: Servlet.service() for servlet appServlet threw exception java.sql.SQLException: 'Infinity' is not a valid numeric or approximate numeric value So it seems one of the Floats or Doubles I am trying to save is infinity.上面写着SEVERE: Servlet.service() for servlet appServlet threw exception java.sql.SQLException: 'Infinity' is not a valid numeric or approximate numeric value所以看起来我要保存的浮点数或双精度数之一是无穷大。 The issue is that ProductionTest is absolutely massive in the sense that it contains Lists of other objects that each have 9 objects that each have Floats and variables, therefore checking each Float or Double in the debug would take ages.问题是 ProductionTest 绝对庞大,因为它包含其他对象的列表,每个对象都有 9 个对象,每个对象都有浮点数和变量,因此在调试中检查每个浮点数或双精度数需要很长时间。
Is there a way I can automate this or make the process faster?有没有办法可以自动化这个或使过程更快? Maybe automate it somehow?也许以某种方式自动化它?

        {
            if(cfam.getRecId()!=null) 
            {
                session.update(cfam);
            } 
            else {
                session.save(cfam);
            }
        }
        save = (Integer) session.save(prodTest);
        prodTest.setRecId(save);
        //my double is for debug purposes
        Double mydouble = Double.POSITIVE_INFINITY;
        session.flush();
    } catch (HibernateException e) {

snippet of the part where it breaks它断裂的部分的片段

Ok, so I found a solution to this.好的,所以我找到了解决方案。 I simply went into the ProductionTest class and generated a new toString method.我只是进入了 ProductionTest class 并生成了一个新的 toString 方法。 Then I added a console print然后我添加了控制台打印

 String output = prodTest.toString();
 System.out.println(output);

Then I copied the 10k char result from the console and pasted it in notepad++ and ctrl+f and searched for infinity.然后我从控制台复制了 10k char 结果并将其粘贴到 notepad++ 和 ctrl+f 中并搜索无穷大。 Found the double that was infinite.找到了无限的替身。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM