KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > PropertyAccessException


1 //$Id: PropertyAccessException.java,v 1.1 2004/06/03 16:30:04 steveebersole Exp $
2
package org.hibernate;
3
4 import org.hibernate.util.StringHelper;
5
6 /**
7  * A problem occurred accessing a property of an instance of a
8  * persistent class by reflection, or via CGLIB. There are a
9  * number of possible underlying causes, including
10  * <ul>
11  * <li>failure of a security check
12  * <li>an exception occurring inside the getter or setter method
13  * <li>a nullable database column was mapped to a primitive-type property
14  * <li>the Hibernate type was not castable to the property type (or vice-versa)
15  * </ul>
16  * @author Gavin King
17  */

18 public class PropertyAccessException extends HibernateException {
19
20     private final Class JavaDoc persistentClass;
21     private final String JavaDoc propertyName;
22     private final boolean wasSetter;
23
24     public PropertyAccessException(Throwable JavaDoc root, String JavaDoc s, boolean wasSetter, Class JavaDoc persistentClass, String JavaDoc propertyName) {
25         super(s, root);
26         this.persistentClass = persistentClass;
27         this.wasSetter = wasSetter;
28         this.propertyName = propertyName;
29     }
30
31     public Class JavaDoc getPersistentClass() {
32         return persistentClass;
33     }
34
35     public String JavaDoc getPropertyName() {
36         return propertyName;
37     }
38
39     public String JavaDoc getMessage() {
40         return super.getMessage() +
41         ( wasSetter ? " setter of " : " getter of ") +
42         StringHelper.qualify( persistentClass.getName(), propertyName );
43     }
44 }
45
46
47
48
49
50
51
Popular Tags