-->
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.  [ 2 posts ] 
Author Message
 Post subject: saveOrUpdate() can't save and can't update
PostPosted: Thu Nov 10, 2005 12:39 pm 
Newbie

Joined: Thu Nov 10, 2005 11:28 am
Posts: 1
Location: Brazil
Hi,

Having a superclass Employee and a subclass ContentProducer mapped
through the "table per subclass" mapping strategy, I cast an Employee
instance to a ContentProducer and tried to save the resulting object
using the saveOrUpdate method(), but with no success.

What happened, I guess, is that at first Hibernate was unable to save
the ContentProducer because of the existing Employee with the same id
in the CONTENT_PRODUCER table. And when trying to update the same
ContentProducer it fails due to the lack of a content producer with
the same id in the CONTENT_PRODUCER table.

The problem is explicited when this exception is raised:

java.lang.IllegalArgumentException: attempt to create saveOrUpdate event with null entity
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:40)
at org.hibernate.event.SaveOrUpdateEvent.<init>(SaveOrUpdateEvent.java:23)
at org.hibernate.impl.SessionImpl.save(SessionImpl.java:480)

Thought I could solve it by changing the mapping stategy to the
"hierarchy per table"; but I´m really lost!

Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 10, 2005 12:53 pm 
Beginner
Beginner

Joined: Tue Jun 14, 2005 12:14 pm
Posts: 37
If you have an Employee instance, then you should try to save it as an Employee instance. Downcasting is dangerous in Hibernate, because of the proxies.

Hope that helps!

Liem


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

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.