标签:mapping reset pointer his element null dma 赋值 val
因为一直报实体类空异常,去网上查了资料只查到了并没有查到数据库空值时不给实体类赋值的属性,只有这两个属性
这两个属性时设置 实体类有空字段插入或更新 数据库时空属性为默认值
异常
org.hibernate.InvalidMappingException: Could not parse mapping document from resource cn/pojo/EmpDao.xml at org.hibernate.cfg.Configuration.addResource(Configuration.java:616) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1635) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556) at org.hibernate.cfg.Configuration.configure(Configuration.java:1476) at org.hibernate.cfg.Configuration.configure(Configuration.java:1462) at cn.tool.HibernateUtil.<clinit>(HibernateUtil.java:16) at cn.service.EmpService.findEmpById(EmpService.java:16) at cn.Test.main(Test.java:9) Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:555) at org.hibernate.cfg.Configuration.addResource(Configuration.java:613) ... 9 more Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Connection reset at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:546) ... 10 more Exception in thread "main" java.lang.NullPointerException at cn.tool.HibernateUtil.currentSession(HibernateUtil.java:29) at cn.service.EmpService.findEmpById(EmpService.java:16) at cn.Test.main(Test.java:9)
于是就加了这段代码
public void setComm(Object comm) { if(comm!=null) this.comm = (double)comm; }
hibernate映射实体类查询时数据库空字段赋值给实体类报错的问题
标签:mapping reset pointer his element null dma 赋值 val
原文地址:https://www.cnblogs.com/hfx123/p/9962076.html