01: //$Id: WrongClassException.java 5685 2005-02-12 07:19:50Z steveebersole $
02: package org.hibernate;
03:
04: import java.io.Serializable;
05:
06: /**
07: * Thrown when <tt>Session.load()</tt> selects a row with
08: * the given primary key (identifier value) but the row's
09: * discriminator value specifies a subclass that is not
10: * assignable to the class requested by the user.
11: *
12: * @author Gavin King
13: */
14: public class WrongClassException extends HibernateException {
15:
16: private final Serializable identifier;
17: private final String entityName;
18:
19: public WrongClassException(String msg, Serializable identifier,
20: String clazz) {
21: super (msg);
22: this .identifier = identifier;
23: this .entityName = clazz;
24: }
25:
26: public Serializable getIdentifier() {
27: return identifier;
28: }
29:
30: public String getMessage() {
31: return "Object with id: " + identifier
32: + " was not of the specified subclass: " + entityName
33: + " (" + super .getMessage() + ")";
34: }
35:
36: public String getEntityName() {
37: return entityName;
38: }
39:
40: }
|