- 浏览: 737303 次
- 性别:
- 来自: 沈阳
最新评论
-
李科笠:
这款编辑器,能够保存从word中复制的图片么?
CKEditor3.x的介绍和使用 -
sybell:
讲得好,但得试一下有没有错。
Mysql 中获取刚插入的自增长id的值 -
zqb666kkk:
nice 很好的启发
spring的jdbcTemplate 返回值为list -
nizen:
不错,有用!
Mysql 中获取刚插入的自增长id的值 -
MEZboy:
真全面,感谢分享!
Radio单选框OnClick事件的设置[网络收集]
错误:org.hibernate.PropertyValueException: not-null property references a null o
- 博客分类:
- 错误日志
junit 错误
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.zyl.po.Card.cardnum
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:95)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:313)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
at org.hibernate.engine.Cascade.cascade(Cascade.java:154)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:357)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.zyl.dao.UserDAO.save(UserDAO.java:16)
at com.zyl.dao.test.UserDAOTestCase.testSaveUsers(UserDAOTestCase.java:23)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
提示很明显,非空的值关联了一个空值或无效的值,就是你数据库里面某个字段设置为非空了,但是传过去的是个空值,仔细检查一下
org.hibernate.PropertyValueException: not-null property references a null or transient value: com.zyl.po.Card.cardnum
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:95)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:313)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:117)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:535)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:527)
at org.hibernate.engine.CascadingAction$5.cascade(CascadingAction.java:241)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:292)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:240)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:193)
at org.hibernate.engine.Cascade.cascade(Cascade.java:154)
at org.hibernate.event.def.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:479)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:357)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:144)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210)
at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195)
at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50)
at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93)
at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:563)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:551)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:547)
at com.zyl.dao.UserDAO.save(UserDAO.java:16)
at com.zyl.dao.test.UserDAOTestCase.testSaveUsers(UserDAOTestCase.java:23)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
提示很明显,非空的值关联了一个空值或无效的值,就是你数据库里面某个字段设置为非空了,但是传过去的是个空值,仔细检查一下
评论
2 楼
Tanxuexiang
2012-09-27
把级联操作cascade设置为all
1 楼
cancan7
2012-06-06
还有种情况是值没传进数据库中去!!!这个解决的问题有点儿棘手,对于目前的我来说,要研究一阵子!!!
发表评论
-
java.lang.OutOfMemoryError: Java heap space
2011-07-29 16:56 790java.lang.OutOfMemoryError: Jav ... -
Access restriction: The type BASE64Decoder is not accessible due to restr[转]
2011-07-05 11:24 2135在Eclipse中编写用java代码时用到了BASE64Dec ... -
No suitable driver found for jdbc[转]
2011-07-05 10:25 951一是:连接URL格式出现了问题(Connection conn ... -
js 写if语句时候的错误
2011-05-20 13:03 791这里的写法很严格...if(){}else if(){}els ... -
java.util.ConcurrentModificationException异常
2011-05-17 13:44 1690java.util.ConcurrentModificatio ... -
update语句
2011-04-27 10:17 756/** * 编辑学员信息 * ... -
Cannot load JDBC driver class 'com.mysql.jdbc.Driver'
2011-04-08 10:22 1100Cannot load JDBC driver class ' ... -
Parameters: Invalid chunk ignored.
2011-04-02 14:21 810引用 警告:Parameters:Invalid chunk ... -
struts2验证信息重复出现
2011-01-24 20:01 728解决的方法:把applicationContext.x ... -
struts2验证问题
2011-01-24 20:00 746起名不对 应该对应上SaveAction.java ... -
The server encountered an internal error () that prevented it from fulfilling th
2011-01-23 20:09 1357spring的applicationContext.xml 改 ... -
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init
2011-01-23 16:45 769多了一个包 asm -
id to load is required for loading
2011-01-22 22:07 3938id to load is required for l ... -
事物没有提交
2011-01-22 11:07 657<aop:pointcut id="allMa ... -
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
2011-01-21 22:52 1268Spring ApplicationContext.xml中报 ... -
hibernate解决延迟加载 [main] ERROR org.hibernate.LazyInitializationException - could n
2011-01-10 21:13 1027[main] ERROR org.hibernat ... -
错误Caused by: Action class [com.zyl.action.LoginAction] does not have a public no
2011-01-06 18:43 1165Caused by: Action class [com.zy ... -
错误Caused by: Action class [com.zyl.action.LoginAction] does not have a public no
2011-01-06 18:22 1034Caused by: Action class [com.zy ... -
js和Html w3c测试 http://w3school.com.cn/
2011-01-05 14:15 2111JS 测验 结果:12/20 您的回答: 1. ... -
w3c测试 http://w3school.com.cn/quiz
2011-01-05 14:09 1985CSS 测验 结果:13/20 您的回答: 1.CSS ...
相关推荐
**PropertyValueException: not-null property references a null or transient value** **异常描述:** 此异常表明一个标记为不可为空的属性引用了一个null或瞬态值。 **解决方法:** - 确认所有标有`not-null`...
在描述中提到的`org.hibernate.PropertyValueException: not-null property references a null or transient value`是Hibernate抛出的一个常见异常,表示尝试保存一个实体时,其某个非空属性为null或未持久化。...
Not-null property references a null or transient value 当Hibernate尝试保存一个实体时,如果该实体中的某个被标记为`@NotNull`或在映射文件中定义为`not-null="true"`的属性值为null或者指向一个尚未持久化的...
org.hibernate.PropertyValueException: not-null property references a null or transient value 当你尝试保存一个实体时,如果该实体中某个被标记为`@NotNull`或`@Column(nullable = false)`的属性值为null,则...
Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................
Not Using Commons Logging ................................................................... 12 Using SLF4J ..............................................................................................
### Hibernate映射关联详解 #### 一、理解一对多双向关联关系 在关系型数据库设计中,一对多关联是常见的数据组织方式之一。而在面向对象编程语言中,这种关系则通常通过集合(如Set或List)来实现。本文将重点...
<property name="username" type="string" column="username" not-null="true"/> <many-to-many class="com.bean.manytomany.Role" column="role_id" /> </hibernate-mapping> ``` `Role.hbm.xml` 示例:...
### Hibernate个人总结 #### 一、理解Hibernate的关系映射 在使用Hibernate进行对象关系映射时,我们需要将实体类与数据库表之间的关系映射清楚。本文档将通过一个简单的例子来展示如何处理一对多(One-to-Many)...
### Hibernate表关联关系详解 #### Many-to-Many 关联关系 在Hibernate中,`many-to-many`关联关系是指两个实体间的一种多对多的关系。这种关系通常需要通过一个中间表来实现,该中间表用于存储两个实体之间的关联...
### Hibernate ORM Mapping详解 #### 一、一对多与一对一映射关系 在关系型数据库中,数据间的关联可以通过一对一、一对多或者多对多的关系来建立。而在Hibernate框架中,这些关系同样可以通过XML配置文件或者注解...
### Hibernate多对多关系配置详解 #### 一、前言 在进行数据库设计与ORM(对象关系映射)框架的应用时,多对多关系是非常常见的一种数据关联方式。本篇文章将详细探讨如何在Hibernate框架中正确配置并实现多对多...
### Hibernate 数据关联详解 #### 一、实验背景与目的 本次实验主要针对Hibernate框架下的数据关联操作进行深入探讨。通过具体实例(多对一关系),理解并掌握如何在Hibernate中实现不同类型的数据关联,并能灵活...
### Hibernate中的关联关系详解 #### 一、Hibernate一对一连接表单向关联 一对一连接表单向关联是指在数据库中通过一张连接表来实现两个表之间的关联,并且这种关联是单向的,即在一个实体中定义了另一个实体的...
### Hibernate映射一对多关联关系 #### 知识点概览 - **概念解析**:一对多(One-to-Many)关联关系的概念及其在Hibernate中的实现方式。 - **域模型设计**:创建具有一个实体与多个实体关联的域模型。 - **关系...
根据给定文件的信息,本文将详细介绍Hibernate ORM(Object Relational Mapping)中关于不同类型的关联映射方式,并结合Annotation和XML两种配置方式来进行说明。 ### 一、一对一单向外键关联 在一对一单向外键...
[RoleId] [int] IDENTITY(1,1) NOT NULL, [RoleName] [varchar](50) COLLATE Chinese_PRC_CI_AS NULL, CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED ([RoleId] ASC) ); CREATE TABLE [dbo].[Users] ( [UserId]...
根据提供的标题、描述、标签及部分内容,我们可以提炼出关于Hibernate框架的一些关键知识点。下面将详细介绍这些知识点,并尽可能地扩展相关内容。 ### Hibernate学习总结 #### 一、Hibernate简介 Hibernate是一个...