KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > PropertyValueException


1 //$Id: PropertyValueException.java,v 1.5 2005/02/12 07:19:50 steveebersole Exp $
2
package org.hibernate;
3
4 import org.hibernate.util.StringHelper;
5
6 /**
7  * Thrown when the (illegal) value of a property can not be persisted.
8  * There are two main causes:
9  * <ul>
10  * <li>a property declared <tt>not-null="true"</tt> is null
11  * <li>an association references an unsaved transient instance
12  * </ul>
13  * @author Gavin King
14  */

15 public class PropertyValueException extends HibernateException {
16
17     private final String JavaDoc entityName;
18     private final String JavaDoc propertyName;
19
20     public PropertyValueException(String JavaDoc s, String JavaDoc entityName, String JavaDoc propertyName) {
21         super(s);
22         this.entityName = entityName;
23         this.propertyName = propertyName;
24     }
25
26     public String JavaDoc getEntityName() {
27         return entityName;
28     }
29
30     public String JavaDoc getPropertyName() {
31         return propertyName;
32     }
33
34     public String JavaDoc getMessage() {
35         return super.getMessage() + ": " +
36             StringHelper.qualify(entityName, propertyName);
37     }
38
39     /**
40      * Return a well formed property path.
41      * Basicaly, it will return parent.child
42      *
43      * @param parent parent in path
44      * @param child child in path
45      * @return parent-child path
46      */

47     public static String JavaDoc buildPropertyPath(String JavaDoc parent, String JavaDoc child) {
48         return new StringBuffer JavaDoc(parent).append('.').append(child).toString();
49     }
50 }
51
52
53
54
55
56
57
Popular Tags