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