<repo_name>Rafasystec/genius-core<file_sep>/genius-core/src/main/java/br/com/barcadero/genius/core/exceptions/ExceptionErroMsg.java
package br.com.barcadero.genius.core.exceptions;

public class ExceptionErroMsg extends Exception{

}
<file_sep>/genius-core/src/main/java/br/com/barcadero/genius/core/role/RoleClient.java
package br.com.barcadero.genius.core.role;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import br.com.barcadero.genius.core.dao.DAOClient;
import br.com.barcadero.genius.core.exceptions.ValidationException;
import br.com.barcadero.genius.persistence.model.Client;


@Service
public class RoleClient extends RoleSuperClass<Client> {

	
	public RoleClient() {
		System.out.println(this.getClass().getName());
	}
	@Autowired
	private DAOClient daoClient;
	@Override
	public Client insert(Client entidade) throws ValidationException {
		return daoClient.insert(entidade);
	}

	@Override
	public void delete(long codigo) throws ValidationException {
		daoClient.delete(codigo);
	}

	@Override
	public Client update(Client entidade) throws ValidationException {
		return daoClient.update(entidade);
	}

	@Override
	public Client find(long codigo) throws ValidationException {
		return daoClient.find(codigo);
	}

}
<file_sep>/genius-core/src/main/java/br/com/barcadero/genius/core/dao/DAOClient.java
package br.com.barcadero.genius.core.dao;

import javax.persistence.NoResultException;

import org.springframework.stereotype.Repository;

import br.com.barcadero.genius.persistence.model.Client;



@Repository
public class DAOClient extends SuperClassDAO<Client> {

	public DAOClient() {
	}
	@Override
	public Client find(long codigo) {
		try{
			return getManager().find(Client.class, codigo);
		}catch(NoResultException e){
			return null;
		}
	}
	
	public void exempleHowToManuallyRemoveInstancesFromPersistenceContext() {
		Client exemplo = find(1l);
		//You don't have to wait for the persistence context to close.
		//You can evict entity instances manually
		getManager().detach(exemplo);
		if(getManager().contains(exemplo)){
			//It will never enter here because the entity was removed
		}
		//Any changes has no effect
	}

}
