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);
	}

}

@@ -42,19 +42,86 @@
 utz.dao.
-Dao
+Cnd;%0D%0Aimport org.nutz.dao.Dao;%0D%0Aimport org.nutz.dao.entity.EntityField
 ;%0D%0A%0D%0Apub
@@ -472,11 +472,227 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09public boolean exists(String name) %7B%0D%0A%09%09EntityField ef = getEntity().getNameField();%0D%0A%09%09if (null == ef)%0D%0A%09%09%09return false;%0D%0A%09%09return dao().count(getEntityClass(), Cnd.where(ef.getFieldName(), %22=%22, name)) %3E 0;%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

Make NameEntityService support exists(String name)