1 package org.hibernate; 3 4 import java.io.Serializable ; 5 6 import org.hibernate.pretty.MessageHelper; 7 8 14 public class UnresolvableObjectException extends HibernateException { 15 16 private final Serializable identifier; 17 private final String entityName; 18 19 public UnresolvableObjectException(Serializable identifier, String clazz) { 20 this("No row with the given identifier exists", identifier, clazz); 21 } 22 UnresolvableObjectException(String message, Serializable identifier, String clazz) { 23 super(message); 24 this.identifier = identifier; 25 this.entityName = clazz; 26 } 27 public Serializable getIdentifier() { 28 return identifier; 29 } 30 31 public String getMessage() { 32 return super.getMessage() + ": " + 33 MessageHelper.infoString(entityName, identifier); 34 } 35 36 public String getEntityName() { 37 return entityName; 38 } 39 40 public static void throwIfNull(Object o, Serializable id, String clazz) 41 throws UnresolvableObjectException { 42 if (o==null) throw new UnresolvableObjectException(id, clazz); 43 } 44 45 } 46 47 48 49 50 51 52 53 | Popular Tags |