-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Is is bug or not?
PostPosted: Fri Apr 14, 2006 7:01 am 
Newbie

Joined: Thu May 27, 2004 12:21 am
Posts: 8
Hibernate version: 3.1.2


Mapping:
I've got class 'MainClass' with collection 'items' with cascade ALL

@OneToMany(cascade={CascadeType.ALL)
@Cascade( org.hibernate.annotations.CascadeType.DELETE_ORPHAN)
@JoinColumn(name="SOME_NAME")
@Sort(type=SortType.COMPARATOR, comparator=MyComparator.class)
private SortedSet<Item> items;

Code between sessionFactory.openSession() and session.close():

// finding mainClass
MainClass mainClass = EntityManager.find(...);

//some actions to initialize collection
mainClass.getItems()
....
//clearing collection and adding new items
mainClass.getItems().clear();
//adding some new items to collection
mainClass.getItems().add(new Item());
...
//need to rollback changes
EntityManager.refresh(mainClass); // exception here occurs

Full stack trace of any exception that occurs:
ERROR [org.hibernate.AssertionFailure] an assertion failure occured (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session)
org.hibernate.AssertionFailure: null identifier
at org.hibernate.engine.EntityKey.<init>(EntityKey.java:33)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:74)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:835)
at org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:829)
at org.hibernate.engine.CascadingAction$4.cascade(CascadingAction.java:92)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:213)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:157)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Cascade.java:290)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java:185)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java:160)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:108)
at org.hibernate.engine.Cascade.cascade(Cascade.java:248)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:99)
at org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:39)
at org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:824)

Solution:
When I remove cascade refresh, no exception.
@OneToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE, CascadeType.REMOVE})


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.