hibernate配置文件:
<hibernate-mapping>
<class name="com.database.BoxBillMng" table="BOX_BILL_MNG" schema="ZHENGJIANG">
<id name="billId" type="java.lang.Long">
<column name="BILL_ID" precision="2" scale="0" />
<generator class="sequence">
<param name="sequence">BoxBILLMng_sequence</param>
</generator>
</id>
<many-to-one name="boxBillType" class="com.database.BoxBillType" fetch="select">
<column name="BILL_TPID" precision="2" scale="0" not-null="true" />
</many-to-one>
<property name="boxMac" type="java.lang.String">
<column name="BOX_MAC" length="12" not-null="true" />
</property>
<property name="icCode" type="java.lang.String">
<column name="IC_CODE" length="20" not-null="true" />
</property>
<property name="userTel" type="java.lang.String">
<column name="USER_TEL" length="15" not-null="true" />
</property>
<property name="billAmnt" type="java.lang.Double">
<column name="BILL_AMNT" precision="10" not-null="true" />
</property>
<property name="appTime" type="java.util.Date">
<column name="APP_TIME" length="7" />
</property>
<property name="openTime" type="java.util.Date">
<column name="OPEN_TIME" length="7" />
</property>
<property name="leftTime" type="java.lang.Long">
<column name="LEFT_TIME" precision="10" scale="0" />
</property>
<property name="state" type="java.lang.Long">
<column name="STATE" precision="1" scale="0" not-null="true" />
</property>
</class>
</hibernate-mapping>
执行查询 List<BoxBillMng> boxBillMngLst = boxBillMngDAO.findByBoxMac(MacAddress);
时报错:Hibernate: select boxbillmng0_.BILL_ID as BILL1_7_, boxbillmng0_.BILL_TPID as BILL2_7_, boxbillmng0_.BOX_MAC as BOX3_7_, boxbillmng0_.IC_CODE as IC4_7_, boxbillmng0_.USER_TEL as USER5_7_, boxbillmng0_.BILL_AMNT as BILL6_7_, boxbillmng0_.APP_TIME as APP7_7_, boxbillmng0_.OPEN_TIME as OPEN8_7_, boxbillmng0_.LEFT_TIME as LEFT9_7_, boxbillmng0_.STATE as STATE7_ from ZHENGJIANG.BOX_BILL_MNG boxbillmng0_ where boxbillmng0_.BOX_MAC=?
java.lang.NullPointerException
at org.hibernate.tuple.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:372)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:3121)
at org.hibernate.event.def.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:232)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:173)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:862)
at org.hibernate.impl.SessionImpl.internalLoad(SessionImpl.java:830)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:266)
at org.hibernate.type.EntityType.resolve(EntityType.java:303)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:116)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:842)
at org.hibernate.loader.Loader.doQuery(Loader.java:717)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:375)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:308)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:153)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1106)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:849)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:840)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
at org.springframework.web.servlet.mvc.SimpleFormController.processFormSubmission(SimpleFormController.java:267)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:265)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:858)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:792)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:476)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:441)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:263)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:584)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
查找问题:org.hibernate.tuple.AbstractEntityTuplizer.createProxy
网上说在<many-to-one name="boxBillType" class="com.hansun.p2pdatabase.BoxBillType" fetch="select">
<column name="BILL_TPID" precision="2" scale="0" not-null="true" />
</many-to-one>
中加 lazy="false" 属性
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-manytoone
加上后 <many-to-one name="boxBillType" lazy="false" class="com.hansun.p2pdatabase.BoxBillType" fetch="select">
<column name="BILL_TPID" precision="2" scale="0" not-null="true" />
</many-to-one>
重启问题解决。
2.插入时出现违反唯一性约束条件的问题,加入dynamic-insert="true" dynamic-update="true"两个属性试试
<class name="com.hansun.p2pdatabase.BoxBillMng" table="BOX_BILL_MNG" schema="ZHENGJIANG" dynamic-insert="true" dynamic-update="true">
分享到:
相关推荐
9. **org.hibernate.tuple**: 用于对象的元数据表示,处理对象的属性值。 10. **org.hibernate.transform**: 结果集转换相关的类,如ResultTransformer,可以将查询结果转换为自定义格式。 另外,"META-INF"目录...
`org.hibernate.tuple.entity.PojoEntityTuplizer`等类展示了这部分功能。 10. **连接池管理**:Hibernate可以与多种连接池(如C3P0、DBCP等)集成,实现数据库连接的高效复用。源码中涉及的`org.hibernate....
for...in循环可以迭代list或tuple中的每个元素,而while循环则可以根据条件重复执行某个操作。 一、for...in循环 for...in循环可以迭代list或tuple中的每个元素。例如: ``` names = ['Michael', 'Bob', 'Tracy'] ...
javax.persistence.Tuple.class javax.persistence.TupleElement.class javax.persistence.TypedQuery.class javax.persistence.UniqueConstraint.class javax.persistence.ValidationMode.class javax.persistence....
HALCON 算子函數 Tuple HALCON 算子函數是一個功能強大且灵活的图像处理系統,Tuple 是 HALCON 算子函數的一個重要组成部分。本章節將詳細介紹 Tuple 的各种算子函數。 Arithmetic Operations: 1. tuple_abs:計...
Python Tuple(元组) tuple()方法描述Python 元组 tuple() 函数将列表转换为元组。语法参数seq -- 要转换为元组的序列。
org.jooq.lambda.tuple 在函数式编程中,元组支持是必不可少的。 可以将各种事物建模为元组,例如函数参数列表。 这就是为什么我们支持类型安全的Tuple1到Tuple16类型的原因。org.jooq.lambda.Seq 实施了新的Streams...
import org.apache.storm.tuple.Fields; import org.apache.storm.tuple.Values; public class StormTest { // 创建拓扑构建器 TopologyBuilder builder = new TopologyBuilder(); // 定义Spout public ...
import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org....
2. clj_tuple$hash_map.class、clj_tuple__init.class、clj_tuple$vector.class、clj_tuple$loading__5569__auto____3668.class、clj_tuple$fn__3670.class:这些看起来是Clojure的元组(tuple)实现,可能用于处理...
import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.streaming.api.datastream.BroadcastConnectedStream; import org.apache.flink.streaming.api.datastream.BroadcastStream; import org....
tuple中元素值排序,取top3 ("测试", (("张三", 5), ("李四", 1), ("王五", 9), ("马六", 6), ("田七", 13), ("赵八", 12))) 结果 ('测试', [('田七', 13), ('赵八', 12), ('王五', 9)])
import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org....
在C++标准库STL中,`std::bind`、`std::tuple`和`std::function`是非常重要的工具,它们提供了高级的函数操作和参数管理能力。下面将详细解释这三个概念及其简单实现的关键点。 首先,我们来看`std::function`。`...
std::tuple与模板元编程 std::tuple是C++标准库中的一种数据结构,用于存储多个值。模板元编程是C++中的一个编程范式,允许开发者在编译时执行计算和元编程。 std::tuple的基本使用 std::tuple是一种 FIXED-SIZE...
import backtype.storm.tuple.Fields; import backtype.storm.tuple.Tuple; import backtype.storm.tuple.Values; public class WordNormalizer extends BaseBasicBolt { public void cleanup() {} /** * The ...
「HALCON算子函數Tuple參考」 HALCON算子函數Tuple參考是HALCON编程语言中的一個重要组成部分,提供了丰富的Tuple操作函數,幫助开发者高效地进行图像處理、数据分析和機器學習等任务。本章節將詳細介紹Tuple的基本...
PYTHON学习教程:使用list和tuple PYTHON学习教程:使用list和tuple是PYTHON学习的基础知识,list和tuple是PYTHON内置的两种数据类型,都是有序的集合,区别在于list是可变的有序表,而tuple是一旦初始化就不能修改...
import org.apache.flink.api.java.tuple.Tuple2; import org.apache.flink.streaming.api.datastream.DataStream; import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; import org....
tuple_utility, 缺少的C++ tuple 功能 tuple_utilityC++ 元组的实用工具。tuple_map:#include"tuple_utility.hpp"int main(){ auto t = std::make_tuple(0, 1