1 21 package net.mlw.vlh.adapter.hibernate3.util.setter; 22 23 import java.text.ParseException ; 24 25 import org.apache.commons.logging.Log; 26 import org.apache.commons.logging.LogFactory; 27 import org.hibernate.HibernateException; 28 import org.hibernate.Query; 29 30 35 public class StringSetter extends AbstractSetter 36 { 37 38 41 private static final Log LOGGER = LogFactory.getLog(StringSetter.class); 42 43 46 public void set(Query query, String key, Object value) throws HibernateException, ParseException 47 { 48 if (LOGGER.isInfoEnabled()) 49 { 50 LOGGER.info("The key='" + key + "' was set to the query as the String='" + value + "'."); 51 } 52 try 53 { 54 query.setString(key, (String ) value); 55 } 56 catch (ClassCastException e) 57 { 58 throw new IllegalArgumentException ("Failed setting a bind variable to a statement because " 59 + "it's of another class than the setter is made for - the variable is " + value.getClass() + " while the setter is " 60 + getClass().getName() + ". Set the correct setter in value list config file - see for example " 61 + "net.mlw.vlh.adapter.jdbc.util.setter.AbstractSetter."); 62 } 63 } 64 } | Popular Tags |