问题描述:Null value was assigned to a property of primitive type setter ,hibernate int型数据无法读取 hiberante读int 整型数据出错 hiberante读数据库出错
错误日志:
Exception in thread "main" org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter of com.zsba.AdornCompanyInfo.provinceOrderMember
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:85)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.setPropertyValues(AbstractEntityTuplizer.java:337)
at org.hibernate.tuple.entity.PojoEntityTuplizer.setPropertyValues(PojoEntityTuplizer.java:200)
at org.hibernate.persister.entity.AbstractEntityPersister.setPropertyValues(AbstractEntityPersister.java:3560)
at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:129)
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.loadEntity(Loader.java:1851)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:48)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3038)
at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:395)
at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:375)
at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:139)
at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:195)
at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:103)
at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:878)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:815)
at org.hibernate.impl.SessionImpl.get(SessionImpl.java:808)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
at $Proxy0.get(Unknown Source)
at com.zsba.HibernateUtil.main(HibernateUtil.java:60)
Caused by: java.lang.IllegalArgumentException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42)
... 26 more
解决办法:
javabean.hbm.xml
<property name="provinceOrderMember" type="int">
<column name="provinceOrderMember">
<comment></comment>
</column>
</property>
type="int" 改为type="java.lang.Integer"
javabean
private int provinceOrderMember; 改为private Intege provinceOrderMember
原因:数据库字段值为NULL,int 类型不能赋值为NULL,只能为0,但有些实际应用中,如学生分数,0表示0分,NULL,则表示暂无分数所以,要不设数据字段不为NULL,要不就是用Integer.
分享到:
相关推荐
功能是工作项的Assigned To字段变化,自动给指派人发送邮件,此结构是host宿主程序,可以将Assigned To更改为其他字段
Visual Studio打开Qt项目时“there's no Qt version assigned to this project for platform win32”问题的解决方法1
- When the signal conditioning function "S&M" was used for a byte value, the driver wrote wrong values to the PLC. Build 223 : New Functions: - The number of supported NetLinks has been ...
After working at Red Hat for a few years, in late 2014 I was assigned to a newly- established team called Cloud Enablement. Our task was to bring the company’s range of middleware products to the ...
After his service with NASA, Lockhart was assigned to and graduated in 2004 from the Royal College of Defence Studies in London, United Kingdom. His last military assignment was with the headquarters ...
July, 3rd, 2015 : 1.5.14 : fixes an information leak vulnerability (CVE-2015-3281) A vulnerability was found ... CVE-2015-3281 was assigned to this bug. Code and changelog are available here as usual.
This property can be assigned by a maximum time, which will be used to calculate the widths of the columns when the user double click on the line that separates columns. If the time of calculation ...
The task of revising this standard was assigned to the Telecommunications and Timing Group (TTG) of the Range Commanders Council (RCC). All U.S. Government ranges and facilities should adhere to this...
[] 匹配中括号里的内容[a-z][A-Z][0-9]。 ! 事件。 $ 取环境变量的值。 | 管道。把前一命令的输出作为后一命令的输入,把几个命令连接起来。 |经常跟tee连用,tee 把内容保存到文档并显示出来。 三、通用后...
After working at Red Hat for a few years, in late 2014 I was assigned to a newlyestablished team called Cloud Enablement. Our task was to bring the company’s range of middleware products to the ...
when no popup menu was assigned to the icon. - ver. 1.0.2: Added a Handle property, and enabled handling of default menu items. (Partially) fixed a bug so the icon will update itself when a new ...
The Graphical Modeling Framework (GMF) project was recently assigned to EMP as a tool for the creation of Graphical Editors for userdefined meta-models. At the same time, GMF itself uses several MDE ...
Creates a cookie, a small amount of information sent by a servlet to a Web browser, saved by the browser, and later sent back to the server. Cookie(String, String) - Constructor for class javax....
This specification was developed in response to a perceived need for a standardized programming inter-face to digitizing tablets, three dimensional position sensors, and other pointing devices by a ...
Used to lock ranges between records in a table to prevent phantom insertions or deletions into a set of records. Ensures serializable transactions. RID A Row Identifier. Used to individually lock a ...
Big Data and IT Professionals: A Study of the Perceptions Held by IT Professionals in Relation to the Maturity, Value, and Practical Deployment of Big Data Solutions This work documents a research ...
The Analysis course was assigned to me due to an emergency redistribution; Topology was thrown in as an award for accepting to teach Analysis on such short notice. Algebraic topology, which covered ...
A task or group of tasks is then assigned to each of the seven OSI layers. Each layer is reasonably self-contained, so that the tasks assigned to each layer can be implemented independently. This ...
not replicated, but is assigned to a particular node based on its contact probability level and node active level. Our scheme is based on a dynamic multicast tree where each leaf node corresponds to a...
This book provides a comprehensive introduction to the modern study of computer algorithms. It presents many algorithms and covers them in considerable depth, yet makes their design and analysis ...