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?
|