Hibernate异常之cascade

  1 org.hibernate.MappingException: Unsupported cascade style: delete-option
  2     at org.hibernate.engine.spi.CascadeStyles.getCascadeStyle(CascadeStyles.java:257)
  3     at org.hibernate.mapping.Property.getCascadeStyle(Property.java:140)
  4     at org.hibernate.mapping.Property.getCollectionCascadeStyle(Property.java:127)
  5     at org.hibernate.mapping.Property.getCascadeStyle(Property.java:102)
  6     at org.hibernate.tuple.PropertyFactory.buildEntityBasedAttribute(PropertyFactory.java:229)
  7     at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:202)
  8     at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:519)
  9     at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124)
 10     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 11     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
 12     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
 13     at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
 14     at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96)
 15     at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77)
 16     at org.hibernate.metamodel.internal.MetamodelImpl.initialize(MetamodelImpl.java:128)
 17     at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:300)
 18     at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:460)
 19     at org.hibernate.boot.internal.MetadataImpl.buildSessionFactory(MetadataImpl.java:170)
 20     at pw.fengya.strategy.TestHibernate.init(TestHibernate.java:26)
 21     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 22     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 23     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 24     at java.lang.reflect.Method.invoke(Method.java:483)
 25     at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
 26     at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
 27     at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeMethodInExtensionContext(ClassTestDescriptor.java:289)
 28     at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$11(ClassTestDescriptor.java:277)
 29     at org.junit.jupiter.engine.descriptor.ClassTestDescriptor$$Lambda$153/1157740463.invokeBeforeEachMethod(Unknown Source)
 30     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$null$2(TestMethodTestDescriptor.java:132)
 31     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$171/597255128.execute(Unknown Source)
 32     at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
 33     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:152)
 34     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:131)
 35     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:106)
 36     at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:57)
 37     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:83)
 38     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$$Lambda$133/1144648478.execute(Unknown Source)
 39     at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
 40     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
 41     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
 42     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$$Lambda$136/1681595665.accept(Unknown Source)
 43     at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
 44     at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
 45     at java.util.Iterator.forEachRemaining(Iterator.java:116)
 46     at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
 47     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
 48     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
 49     at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
 50     at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
 51     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
 52     at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
 53     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
 54     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$$Lambda$133/1144648478.execute(Unknown Source)
 55     at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
 56     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
 57     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$null$2(HierarchicalTestExecutor.java:92)
 58     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$$Lambda$136/1681595665.accept(Unknown Source)
 59     at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
 60     at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
 61     at java.util.Iterator.forEachRemaining(Iterator.java:116)
 62     at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
 63     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:512)
 64     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:502)
 65     at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
 66     at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
 67     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
 68     at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
 69     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$3(HierarchicalTestExecutor.java:92)
 70     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor$$Lambda$133/1144648478.execute(Unknown Source)
 71     at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
 72     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:77)
 73     at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:51)
 74     at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)
 75     at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:170)
 76     at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:154)
 77     at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:90)
 78     at org.eclipse.jdt.internal.junit5.runner.JUnit5TestReference.run(JUnit5TestReference.java:86)
 79     at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 80     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:538)
 81     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:760)
 82     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:460)
 83     at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:206)
 84     Suppressed: java.lang.NullPointerException
 85         at pw.fengya.strategy.TestHibernate.destory(TestHibernate.java:39)
 86         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 87         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 88         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 89         at java.lang.reflect.Method.invoke(Method.java:483)
 90         at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:389)
 91         at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:115)
 92         at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeMethodInExtensionContext(ClassTestDescriptor.java:289)
 93         at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$synthesizeAfterEachMethodAdapter$12(ClassTestDescriptor.java:281)
 94         at org.junit.jupiter.engine.descriptor.ClassTestDescriptor$$Lambda$156/1582797472.invokeAfterEachMethod(Unknown Source)
 95         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$null$9(TestMethodTestDescriptor.java:208)
 96         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$195/1112758237.execute(Unknown Source)
 97         at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
 98         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeAllAfterMethodsOrCallbacks$13(TestMethodTestDescriptor.java:226)
 99         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor$$Lambda$194/2108440536.accept(Unknown Source)
100         at java.util.ArrayList.forEach(ArrayList.java:1234)
101         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAllAfterMethodsOrCallbacks(TestMethodTestDescriptor.java:224)
102         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeAfterEachMethods(TestMethodTestDescriptor.java:207)
103         at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:114)
104         ... 48 more

Hibernate创建双向一对多关联关系时报错,报错信息:org.hibernate.MappingException: Unsupported cascade style: delete-option,原因是在这个配置文件是从上一个项目中直接复制的,配置文件中没有去掉cascade="delete-option",去掉后正常运行

<set name="orders" table="ORDERS" inverse="true" cascade="delete-option">
            <key column="CUSTOMER_ID" />
            <one-to-many class="Order" />
</set>

原文地址:https://www.cnblogs.com/lxc-2017/p/8547915.html

时间: 2024-11-11 19:20:22

Hibernate异常之cascade的相关文章

Hibernate inverse 和 cascade 的阐释

前提: inverse:负责外键维护; cascade:负责记录的添加删除修改;基础: Hibernate中的"inverse"属性只有两个值"true"和"false"."true"表示将关系维护的权力交给对方,"false"表示不交出维护权力(默认值). Hibernate中的"cascade"-书面化的解释为"该属性会使我们在操作主对象时,同时Hibernate帮助我们完

Hibernate 异常 : Error parsing JNDI name [xxx]

初学 Hibernate ,用官方给的日志模板配置好了日志,跑起小例子, 控制台中的日志里写了一些异常: 21:16:36,036 DEBUG EntityLoader:146 -  Static select for entity cn.sjll.hibernate435.model.UserModel  [OPTIMISTIC_FORCE_INCREMENT]: select usermodel0_.ID as ID1_0_0_,  usermodel0_.NAME as NAME2_0_0

利用struts进行前端页面间传值及hibernate异常:a different object with the same identifier value was already associated with the session的总结

2017-3-16 我使用SSH框架在做单表CRUD的更新操作时遇到了一个问题,就是页面间该怎么传值?解决该需求时引发了一系列的bug,趁还记得好好总结一番. 前端页面间传值 情景:在我查出所以记录后,点击修改会链接到新的修改页面. 问题:该新页面没有之前的实体信息,该如何传递要修改的实体信息给该页面,例如id? 思路1:利用struts的action来传值. 1 <form action="deleteSerCate.action" method="post"

Hibernate 配置文件 细节 cascade inverse

今天写东西,在配置关系时 ,随后就将cascade 配置, 而且配的值是false . 尼玛 ,结果很悲催,已启动就报错 ,弄得我云里雾里的,后来仔细检查发现原来是cascade在做该.现总结一下.顺便复习一下inverse . 1.cascade 层叠,有了它我们在操作删除和更新的时候会更加方便.只要在cascade的源头插入或者删除,所有cascade 的关系就会被动的插入或者删除.cascade 有一个值很重要,saveOrUpdate ,Hibernate根据这个属性值来判断一个对象时插

Hibernate异常:java.lang.NoClassDefFoundError: org/objectweb/asm/Type

解决方法:将Hibernate lib包下的asm.jar添加到项目的library中. 解决方法:将Hibernate lib包下的cglib-2.1.3.jar添加到项目的library中.  Hibernate异常:java.lang.NoClassDefFoundError: org/objectweb/asm/Type

hibernate 的配置 cascade

在hibernate中删除一对多中的多方数据时报错: org.hibernate.ObjectDeletedException : deleted object would be re-saved by cascade (remove deleted object from associations): [pojos.UdData#40288669477c2dd501477c2dd6140002] 分析: 字面意思是“被删除的数据因为cascade选项将会被重新保存[方法:将该数据从关联关系中移

Hibernate 异常总结

异常一 异常一 异常描述: Sax解析异常:cvc-复杂的类型,发现了以元素maping开头的无效内容,应该是以 '{"http://www.hibernate.org/xsd/orm/cfg":property, "http://www.hibernate.org/xsd/orm/cfg":mapping, "http://www.hibernate.org/xsd/orm/cfg":class-cache, "http://www.

Hibernate异常No row with the given identifier exists

package com.prms.urms.entity; import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.En

hibernate中的cascade和inverse

在hibernate中表间的关系维护是最重要的,而这又与cascade和inverse是分不开的. 表结构:学生和课程是多对多的关系,通过第三张表来映射来者间的关系. 类结构: 下面来保存一些数据: @Test public void save() { Session session = factory.openSession(); session.getTransaction().begin(); Course course = new Course(); course.setCname("数