import org.apache.commons.lang.StringUtils;
public class AttributeRepositoryImpl implements AttributeRepository {
public void setAttribute(int targetId, String name, String value) throws RepositoryException {
try {
final Session session = ThreadSession.get();
final Attribute attribute = new Attribute(targetId, name, value);
List existingAttributes = session.find("from a in "+Attribute.class+
" where targetId = ? and name= ?",
new Object[]{ new Integer(targetId), name },
new Type[]{ Hibernate.INTEGER, Hibernate.STRING });
if (existingAttributes.size() == 0) {
session.save(attribute);
} else {
session.update(attribute);
}
} catch (RuntimeException e) {
throw e;
} catch (HibernateException e) {
throw new RepositoryException(e);