KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > WrongClassException


1 //$Id: WrongClassException.java,v 1.3 2005/02/12 07:19:50 steveebersole Exp $
2
package org.hibernate;
3
4 import java.io.Serializable JavaDoc;
5
6 /**
7  * Thrown when <tt>Session.load()</tt> selects a row with
8  * the given primary key (identifier value) but the row's
9  * 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 JavaDoc identifier;
17     private final String JavaDoc entityName;
18
19     public WrongClassException(String JavaDoc msg, Serializable JavaDoc identifier, String JavaDoc clazz) {
20         super(msg);
21         this.identifier = identifier;
22         this.entityName = clazz;
23     }
24     public Serializable JavaDoc getIdentifier() {
25         return identifier;
26     }
27
28     public String JavaDoc getMessage() {
29         return "Object with id: " +
30             identifier +
31             " was not of the specified subclass: " +
32             entityName +
33             " (" + super.getMessage() + ")" ;
34     }
35
36     public String JavaDoc getEntityName() {
37         return entityName;
38     }
39
40 }
41
42
43
44
45
46
47
48
Popular Tags