Cascade.cascadeCollectionElements ClastCastException for non-entity element types

Description

When trying to flush changes in EntityMode.DOM4J, a composite element causes a ClassCastException in Cascade.cascadeCollectionElements when invoked by Cascade.cascadeCollection. The latter allows the call to the former when the element is of ComponentType, but assumes in the former always casts to EntityType if EntityMode.DOM4J is in effect.

Possible patch:

diff -u -r1.1 Cascade.java
— src/org/hibernate/engine/Cascade.java 3 Jul 2007 20:12:01 -0000 1.1
+++ src/org/hibernate/engine/Cascade.java 30 Jul 2007 19:42:54 -0000
@@ -281,7 +281,7 @@
final boolean isCascadeDeleteEnabled) throws HibernateException {
// we can't cascade to non-embedded elements
boolean embeddedElements = eventSource.getEntityMode()!=EntityMode.DOM4J ||
- ( (EntityType) collectionType.getElementType( eventSource.getFactory() ) ).isEmbeddedInXML();
+ ( elemType.isEntityType() && ( (EntityType) elemType ).isEmbeddedInXML() );

boolean reallyDoCascade = style.reallyDoCascade(action) &&
embeddedElements && child!=CollectionType.UNFETCHED_COLLECTION;

Activity

Brett MeyerOctober 31, 2013 at 12:49 PM

Bulk closing issues related to EntityMode.DOM4J. Mode was removed in HHH-6330.

Out of Date

Details

Assignee

Reporter

Affects versions

Priority

Created July 30, 2007 at 9:47 PM
Updated October 31, 2013 at 12:49 PM
Resolved October 31, 2013 at 12:49 PM