org.hibernate.PropertyValueException Maven / Gradle / Ivy
//$Id: PropertyValueException.java 5685 2005-02-12 07:19:50Z steveebersole $
package org.hibernate;
import org.hibernate.util.StringHelper;
/**
* Thrown when the (illegal) value of a property can not be persisted.
* There are two main causes:
*
* - a property declared not-null="true" is null
*
- an association references an unsaved transient instance
*
* @author Gavin King
*/
public class PropertyValueException extends HibernateException {
private final String entityName;
private final String propertyName;
public PropertyValueException(String s, String entityName, String propertyName) {
super(s);
this.entityName = entityName;
this.propertyName = propertyName;
}
public String getEntityName() {
return entityName;
}
public String getPropertyName() {
return propertyName;
}
public String getMessage() {
return super.getMessage() + ": " +
StringHelper.qualify(entityName, propertyName);
}
/**
* Return a well formed property path.
* Basicaly, it will return parent.child
*
* @param parent parent in path
* @param child child in path
* @return parent-child path
*/
public static String buildPropertyPath(String parent, String child) {
return new StringBuffer(parent).append('.').append(child).toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy