reset password
Author Message
ashoush
Posts: 25
Posted 00:00 Oct 31, 2009 |

Hi,

I am using the discriminator method for definig my OnlineSubmission and OnlineAssignment subclasses in Hibernate. The problem is when I go to CSNS, for the normal Assignment or Submissions (for which the discriminator value is NULL), I get this exception:

Caused by: org.hibernate.WrongClassException: Object with id: 70008 was not of the specified subclass: csns.model.Submission (Discriminator: null)
    at org.hibernate.loader.Loader.getInstanceClass(Loader.java:1453)
    at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1284)
    at org.hibernate.loader.Loader.getRow(Loader.java:1206)

I found an article regarding this issue here:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-1621

But it is suggesting to change the hibernate source files, which I think is not a good idea. Anybody had a similar experience, or know the solution?

cysun
Posts: 2935
Posted 00:11 Oct 31, 2009 |

The super class Assignment/Submission needs a discriminator value, too, e.g.

<class name="Assignment" table="assignments" discriminator-value="REGULAR"> ...

<subclass name="OnlineAssignment" discriminator-value="ONLINE"> ...

Note that this is different from the case of Question and Answer, which are abstract classes. 

ashoush
Posts: 25
Posted 09:32 Oct 31, 2009 |

Thanks a lot Dr. Sun.