package org.nutz.service;

import org.nutz.dao.Dao;

public abstract class NameEntityService<T> extends EntityService<T> {

	protected NameEntityService() {
		super();
	}

	protected NameEntityService(Dao dao) {
		super(dao);
	}

	public void delete(String name) {
		dao().delete(getEntityClass(), name);
	}

	public T fetch(String name) {
		return dao().fetch(getEntityClass(), name);
	}

}

package org.nutz.service;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.entity.EntityField;

public abstract class NameEntityService<T> extends EntityService<T> {

	protected NameEntityService() {
		super();
	}

	protected NameEntityService(Dao dao) {
		super(dao);
	}

	public void delete(String name) {
		dao().delete(getEntityClass(), name);
	}

	public T fetch(String name) {
		return dao().fetch(getEntityClass(), name);
	}

	public boolean exists(String name) {
		EntityField ef = getEntity().getNameField();
		if (null == ef)
			return false;
		return dao().count(getEntityClass(), Cnd.where(ef.getFieldName(), "=", name)) > 0;
	}

}

Make NameEntityService support exists(String name)