001 package net.databinder.models.hib;
002
003
004 import org.apache.wicket.util.lang.PropertyResolver;
005 import org.hibernate.Query;
006
007 /**
008 * Base class for classes that bind queries using object properties.
009 *
010 * @author Jonathan
011 */
012 public abstract class AbstractPropertyQueryBinder implements QueryBinder {
013
014 private static final long serialVersionUID = 145077736634107819L;
015
016 /**
017 * @param query
018 * The query to bind
019 * @param object
020 * The object to pull properties from
021 */
022 protected void bind(final Query query, final Object object) {
023 for (final String parameter : query.getNamedParameters()) {
024 query.setParameter(parameter, PropertyResolver.getValue(parameter,
025 object));
026 }
027 }
028 }