01: //$Id: PropertyAccessException.java 3890 2004-06-03 16:31:32Z steveebersole $
02: package org.hibernate;
03:
04: import org.hibernate.util.StringHelper;
05:
06: /**
07: * A problem occurred accessing a property of an instance of a
08: * persistent class by reflection, or via CGLIB. There are a
09: * 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 persistentClass;
21: private final String propertyName;
22: private final boolean wasSetter;
23:
24: public PropertyAccessException(Throwable root, String s,
25: boolean wasSetter, Class persistentClass,
26: String propertyName) {
27: super (s, root);
28: this .persistentClass = persistentClass;
29: this .wasSetter = wasSetter;
30: this .propertyName = propertyName;
31: }
32:
33: public Class getPersistentClass() {
34: return persistentClass;
35: }
36:
37: public String getPropertyName() {
38: return propertyName;
39: }
40:
41: public String getMessage() {
42: return super .getMessage()
43: + (wasSetter ? " setter of " : " getter of ")
44: + StringHelper.qualify(persistentClass.getName(),
45: propertyName);
46: }
47: }
|