Problema com merge do JPA

6 respostas
Jr_webmaster_100_jav

galera esta acontecendo algo estranho comigo, seguinte...

tenho o metodo para alterar o registro no banco de dados.

o metodo e o seguinte.

public void alterar(Vendedor vendedor) throws PessoaException
    {
    	//Pessoa pessoa = new Pessoa();
    	
        if(vendedor.getNomeCompleto().isEmpty() == true){
                throw new PessoaException("N�o pode grava com Nome em Branco!");
        }
        
        EntityManager em = EntityManagerUtil.getEntityManager();
        EntityTransaction tx = em.getTransaction();
        
        try {
        	tx.begin();
        	em.merge(vendedor);
            tx.commit();

		   }
        catch (Exception e)
        {
        	e.printStackTrace();
            tx.rollback();
        }
		finally
		{
			em.close();
		}
     
     
    }

ele funciona tranquilamente o alterar ( vendedor )

agora tenho esse mesmo metodo no dao de clientes

public void editarCliente(Cliente cliente) throws PessoaException{

	        if(cliente.getNomeCompleto().isEmpty() == true){
	                throw new PessoaException("N�o pode grava com Nome em Branco!");
	        }
	        
	        EntityManager em = EntityManagerUtil.getEntityManager();
	        EntityTransaction tx = em.getTransaction();
	        
	        try {
	        	tx.begin();
	        	em.merge(cliente);
	            tx.commit();

			   }
	        catch (Exception e)
	        {
	        	e.printStackTrace();
	            tx.rollback();
	        }
			finally
			{
				em.close();
			}
	    }

e inves dele fazer um update na tabela ao executar o em.merge ele faz um select somente.

no de vendedor funciona, do de cliente nao.

alguma ideia ?

6 Respostas

drsmachado

Isso está muito estranho. Já debugou para ver se o fluxo ocorre normalmente? merge fazer select, nunca vi.

Jr_webmaster_100_jav

ta normal sim, ja debuguei inueras vezes… tambe, achei muito estrando, pois sempre usei o merge para realizar a atualizacao

Polverini

aconteceu comigo ja, cola um input hidden contendo o id do cliente que vc quer atualizar. ex:

<h:inputHidden value="#{clienteController.cliente.id}"/>
Jr_webmaster_100_jav

Amigo continua realizando o select

aqui esta o codigo das 2 classes que utilizo

package org.smartgestor.dao;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.persistence.Query;
import javax.servlet.http.HttpSession;
import javax.swing.JOptionPane;

import org.primefaces.event.FlowEvent;
import org.primefaces.event.SelectEvent;
import org.smartgestor.cadastro.Cliente;
import org.smartgestor.cadastro.Endereco;
import org.smartgestor.excessao.PessoaException;
import org.smartgestor.faces.ClienteFaces;
import org.smartgestor.util.EntityManagerUtil;
import org.smartgestor.util.WebServiceFront;



public class ClienteDAO implements Serializable{

	private static final long serialVersionUID = 1L;
	private Cliente clienteEdit = new Cliente();
	private String tipo;
	private Endereco enderecoCADEdicao = new Endereco();
	private Endereco enderecoCOBEdicao = new Endereco();
	private List<Endereco> enderecos = new ArrayList<Endereco>();
	private boolean skip;  
	private String cepEdicao;
	private String cepCOBEdicao;
	
	
    

	public String getCepEdicao() {
		return cepEdicao;
	}
	public void setCepEdicao(String cepEdicao) {
		this.cepEdicao = cepEdicao;
	}
	public Endereco getEnderecoCADEdicao() {
		return enderecoCADEdicao;
	}
	public void setEnderecoCADEdicao(Endereco enderecoCADEdicao) {
		this.enderecoCADEdicao = enderecoCADEdicao;
	}
	public Endereco getEnderecoCOBEdicao() {
		return enderecoCOBEdicao;
	}
	public void setEnderecoCOBEdicao(Endereco enderecoCOBEdicao) {
		this.enderecoCOBEdicao = enderecoCOBEdicao;
	}
	public List<Endereco> getEnderecos() {
		return enderecos;
	}
	public void setEnderecos(List<Endereco> enderecos) {
		this.enderecos = enderecos;
	}
	public String getTipo() {
		return tipo;
	}
	public void setTipo(String tipo) {
		this.tipo = tipo;
	}
	public ClienteDAO(Cliente clienteEdit) {
		this.clienteEdit = clienteEdit;
	}
	public String inicializar(){
		clienteEdit = new Cliente();
		return "Cadastrado";
	}
	public ClienteDAO(){
		this.clienteEdit = new Cliente();
	}
	
	public void salvarCliente(ActionEvent event) {
		//System.out.println("Executou o metodo");
		HttpSession sessao = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		FacesContext context = FacesContext.getCurrentInstance();
		try {
			this.clienteEdit = (Cliente)sessao.getAttribute("objcli");
			this.enderecoCADEdicao = (Endereco)sessao.getAttribute("objEndCad");
			this.enderecoCOBEdicao = (Endereco)sessao.getAttribute("objEndCob");
			//this.enderecoCADEdicao.setCep(cepEdicao);
			//this.enderecoCOBEdicao.setCep(cepCOBEdicao);
			this.enderecos.add(enderecoCADEdicao);
			this.enderecos.add(enderecoCOBEdicao);
			String aux = (String) event.getComponent().getAttributes().get("tipopessoa");
			clienteEdit.setTipopessoa(aux.charAt(0));
			clienteEdit.setEndereco(enderecos);
			
			new ClienteFaces().salvar(this.clienteEdit);
			String texto = "Nome = "+clienteEdit.getNomeCompleto()+
			"Tipo Pessoa: "+clienteEdit.getTipopessoa();
			System.out.println(texto);
			
			this.clienteEdit = new Cliente();
			FacesMessage msg = new FacesMessage("Cliente Salvo com Sucesso!");
			msg.setSeverity(FacesMessage.SEVERITY_INFO);
			context.addMessage(null, msg);
			sessao.setAttribute("objEndCad", null);
			sessao.setAttribute("objEndCob", null);
			sessao.setAttribute("objcli", null);
            
		} catch (PessoaException e) {
			context.addMessage(
					null,
					new FacesMessage(FacesMessage.SEVERITY_ERROR, e
							.getMessage(), e.getMessage()));
		} catch (Exception e) {
			e.printStackTrace();
			FacesMessage msg = new FacesMessage(
					"Erro inesperado ao salvar o cliente!");
			
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			context.addMessage(null, msg);
		}

	}
	
	
	public void removerCliente(ActionEvent event) {
		//System.out.println("Executou o metodo");
		FacesContext context = FacesContext.getCurrentInstance();
		try {
			new ClienteFaces().excluir(this.clienteEdit);
			this.clienteEdit = new Cliente();
			FacesMessage msg = new FacesMessage("Cliente removido com Sucesso!");
			msg.setSeverity(FacesMessage.SEVERITY_INFO);
			context.addMessage(null, msg);

		} catch (Exception e) {
			e.printStackTrace();
			FacesMessage msg = new FacesMessage(
					"Erro inesperado ao remover o cliente!");
			JOptionPane.showMessageDialog(null, msg);
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			context.addMessage(null, msg);
		}

	}
	
	
	public void alterarClienteEdicao(ActionEvent event) {
		FacesContext context = FacesContext.getCurrentInstance();
		System.out.println("chamou o metodo");
		try {
			new ClienteFaces().editarCliente(clienteEdit);
			this.clienteEdit = new Cliente();
			FacesMessage msg = new FacesMessage("Cliente Salvo com Sucesso!");
			msg.setSeverity(FacesMessage.SEVERITY_INFO);
			context.addMessage(null, msg);

		} catch (Exception e) {
			e.printStackTrace();
			FacesMessage msg = new FacesMessage(
					"Erro inesperado ao salvar o Cliente!");
			JOptionPane.showMessageDialog(null, msg);
			msg.setSeverity(FacesMessage.SEVERITY_ERROR);
			context.addMessage(null, msg);
		}

	}
	
	public String alteraPrepara(ActionEvent event)
	{
	
		String aux = String.valueOf(clienteEdit.getTipopessoa());
		if(aux.equals("F"))
		{
			//pessoa fisica
			return "clientePF.faces";
		}
		else if(aux.equals("J"))	
		{
			// pessoa juridica
			return "clientePJ.faces";
		}else
		{
			return "erro.faces";
		}
	}
	
	
	
	
	

	
	public Cliente getClienteEdit() {
		return clienteEdit;
	}
	public void setClienteEdit(Cliente clienteEdit) {
		this.clienteEdit = clienteEdit;
		String texto = "Nome = "+clienteEdit.getNomeCompleto()+
		"\nTipo Pessoa: "+clienteEdit.getTipopessoa();
		System.out.println(texto);
	}
	public void selecionar(SelectEvent event)
	{
		this.clienteEdit = (Cliente)event.getObject();
		this.clienteEdit = recuperaCliente(clienteEdit.getiD());
		enderecoCADEdicao = clienteEdit.getEnderecos().get(0);
		enderecoCOBEdicao = clienteEdit.getEnderecos().get(1);
		cepEdicao = enderecoCADEdicao.getCep();
		cepCOBEdicao = enderecoCOBEdicao.getCep();
		//System.out.println("Nome: "+clienteEdit.getNomeCompleto()+"\nTipo Pessoa: "+clienteEdit.getTipopessoa()+"\nCodigo: "+clienteEdit.getiD());
	}

	private Cliente recuperaCliente(Long getiD) {
		
		Cliente cl = null;
		
		Query query = EntityManagerUtil.getEntityManager().createQuery("select c from Cliente c fetch all properties where c.iD = :codigo");
		query.setParameter("codigo", getiD);
		
		try {
			cl = (Cliente) query.getSingleResult();
		} catch (Exception e) {
			
		}
		
		return cl;
	}
	public String onFlowProcess(FlowEvent event) {  
		System.out.println("Current wizard step:" + event.getOldStep());
        //logger.info(); 
		System.out.println("Next step:" + event.getNewStep());
        //logger.info();  
		HttpSession sessao = (HttpSession)FacesContext.getCurrentInstance().getExternalContext().getSession(true);
		if(event.getNewStep().equals("enderecoCad"))
		{
			String texto = "Nome = "+clienteEdit.getNomeCompleto()+
			"\nTipo Pessoa: "+clienteEdit.getTipopessoa();
			System.out.println(texto);
			
			sessao.setAttribute("objcli", clienteEdit);
		}
		
		if(event.getNewStep().equals("enderecoCob"))
		{
			System.out.println("Salva o Endereco de Cadastro");
			enderecoCADEdicao.setCep(cepEdicao);
			this.enderecos.add(enderecoCADEdicao);
			//this.enderecoCADEdicao = new Endereco();
			this.clienteEdit = (Cliente)sessao.getAttribute("objcli");
			sessao.setAttribute("objEndCad", enderecoCADEdicao);
		}
          
		if(event.getNewStep().equals("confirmation"))
		{
			System.out.println("Salva o Endereco de Cobranca");
			enderecoCOBEdicao.setCep(cepCOBEdicao);
			this.enderecos.add(enderecoCOBEdicao);
			//this.enderecoCOBEdicao = new Endereco();
			this.clienteEdit = (Cliente)sessao.getAttribute("objcli");
			this.enderecoCADEdicao = (Endereco) sessao.getAttribute("objEndCad");
			sessao.setAttribute("objEndCob", enderecoCOBEdicao);
		}
		
        if(skip) {  
            skip = false;   //reset in case user goes back  
            return "confirm";  
        }  
        else {  
            return event.getNewStep();  
        }  
    }
	
	
	public void preecheEnderecoCad(ActionEvent event)
	{
		WebServiceFront servico = new WebServiceFront();
		servico.buscaPorCEP(this.cepEdicao);
		this.enderecoCADEdicao.setCep(this.cepEdicao);
		
		if(servico.isEncontrou())
		{
			this.enderecoCADEdicao.setLogradouro(servico.getLogradouro());
			this.enderecoCADEdicao.setBairro(servico.getBairro());
			this.enderecoCADEdicao.setCidade(servico.getCidade());
			this.enderecoCADEdicao.setUf(servico.getUf());
			this.enderecoCADEdicao.setTipo(servico.getTipoEndereco());
			
			
		}
	}
	
	public void preecheEnderecoCob(ActionEvent event)
	{
		WebServiceFront servico = new WebServiceFront();
		servico.buscaPorCEP(this.cepCOBEdicao);
		this.enderecoCOBEdicao.setCep(this.cepCOBEdicao);
		//System.out.println("cep = "+this.cepEdicao);
		if(servico.isEncontrou())
		{
			this.enderecoCOBEdicao.setLogradouro(servico.getLogradouro());
			this.enderecoCOBEdicao.setBairro(servico.getBairro());
			this.enderecoCOBEdicao.setCidade(servico.getCidade());
			this.enderecoCOBEdicao.setUf(servico.getUf());
			this.enderecoCOBEdicao.setTipo(servico.getTipoEndereco());
			
			
		}
	}
	
	
	public void setCepCOBEdicao(String cepCOBEdicao) {
		this.cepCOBEdicao = cepCOBEdicao;
	}
	public String getCepCOBEdicao() {
		return cepCOBEdicao;
	}
	
	public void editarCliente(ActionEvent event) throws PessoaException
	{
		System.out.println("executou");
		
		new ClienteFaces().editarCliente(clienteEdit);
		FacesContext.getCurrentInstance().addMessage("Sucesso", new FacesMessage("Cliente Alterado com Exito"));
	}
	 
	public void teste(ActionEvent evt)
	{
		System.out.println("executou");
	}

}
package org.smartgestor.faces;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Logger;


import javassist.expr.NewArray;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import javax.servlet.http.HttpServletResponse;
import org.hibernate.Session;
import org.hibernate.criterion.Order;
import org.primefaces.event.FlowEvent;
import org.smartgestor.cadastro.Cliente;
import org.smartgestor.cadastro.Endereco;
import org.smartgestor.excessao.PessoaException;
import org.smartgestor.util.EntityManagerUtil;

public class ClienteFaces implements Serializable{

	private static final long serialVersionUID = 1L;
	private Cliente clienteEdicao = new Cliente();
	private int Escolha;
	private List<Cliente> clientes;
	private String tipo;
	private Endereco enderecoEdicao;
	private List<Endereco> enderecos = new ArrayList<Endereco>();
	private boolean skip;  
    
    private static Logger logger = Logger.getLogger(ClienteFaces.class.getName());
	
	
	
	public ClienteFaces() {
		//ListaDeCliente();
		
	}
	
	public void editar(ActionEvent event)
	{
		System.out.println("Cliente nome : "+clienteEdicao.getNomeCompleto());
		
		HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
		
		try {
			response.sendRedirect("clientePF.faces");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public void inserir(ActionEvent event) 
	{
		    
		try {
			clienteEdicao.setTipopessoa(tipo.charAt(0));
			salvar(clienteEdicao);
			this.clienteEdicao = new Cliente();
			//return "inserido.faces";
		} catch (PessoaException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			//return "erro.faces";
		}
		
	}
	
	
	public void salvar(Cliente cliente) throws PessoaException
    {
		Date Data = new Date();
		
        if(cliente.getNomeCompleto().isEmpty() == true){
                throw new PessoaException("Nao pode gravar com Nome em Branco!");
        }
     
               EntityManager em = EntityManagerUtil.getEntityManager();
               EntityTransaction t = em.getTransaction();
            
            try {
            	t.begin();
                cliente.setDataCadastro(Data);
                em.persist(cliente);
                t.commit();
                

                
    		} catch (Exception e) {
    			e.printStackTrace();
    			t.rollback();
    			
    		}
    		finally
    		{
    		  fechaSessao(em);
    		}
    	
     
    }
	
	 
		private void fechaSessao(EntityManager em) {
			if(em.isOpen())
			  {
				  em.close();
			  }
		
	}

		
		@SuppressWarnings("unchecked")
		public void ListaDeCliente(){
			EntityManager em = EntityManagerUtil.getEntityManager();
	        Session session = (Session) em.getDelegate();
	        try{
	        	clientes = session.createCriteria(Cliente.class).addOrder(Order.asc("id")).list();
	            
	        }finally{
	            session.close();
	        }
	    }
	 
	   
	    
	    public void excluir(Cliente cliente){

	    	EntityManager em = EntityManagerUtil.getEntityManager();
            EntityTransaction t = em.getTransaction();
	        
	        try {
	            t.begin();
	            Cliente c = new Cliente();
	            c = em.merge(cliente);
	            em.remove(c);
	            t.commit();

			} catch (Exception e) {
				e.printStackTrace();
				t.rollback();
			}
			finally
			{
			  fechaSessao(em);
			}
	    }
	    
	    
	    public void editarCliente(Cliente cliente) throws PessoaException{

	        if(cliente.getNomeCompleto().isEmpty() == true){
	                throw new PessoaException("N&#65533;o pode grava com Nome em Branco!");
	        }
	        
	        EntityManager em = EntityManagerUtil.getEntityManager();
	        EntityTransaction tx = em.getTransaction();
	        
	        try {
	        	tx.begin();
	        	em.merge(cliente);
	        	
	            tx.commit();

			   }
	        catch (Exception e)
	        {
	        	e.printStackTrace();
	            tx.rollback();
	        }
			finally
			{
				em.close();
			}
	    }
		
	    
	    

	public Cliente getClienteEdicao() {
		return clienteEdicao;
	}


	public void setClienteEdicao(Cliente clienteEdicao) {
		this.clienteEdicao = clienteEdicao;
	}


	public int getEscolha() {
		return Escolha;
	}


	public void setEscolha(int escolha) {
		Escolha = escolha;
	}


	public static long getSerialversionuid() {
		return serialVersionUID;
	}


	public List<Cliente> getClientes() {
		ListaDeCliente();
		return clientes;
	}


	public void setClientes(List<Cliente> clientes) {
		this.clientes = clientes;
	}

	public String getTipo() {
		return tipo;
	}

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}
	
	public String abreFormulario()
	{
		if(tipo.equals("F"))
		{
			return "addCliente.faces?tipo=1";
		}
		else if(tipo.equals("J"))
		{
			return "addCliente.faces?tipo=2";
		}
		else
		{
		  FacesMessage msg = new FacesMessage("Selecione um tipo de Pessoa");
		  FacesContext.getCurrentInstance().addMessage(null,msg);
		  return "";
		  
		
		}
		
	}
	
	public String selecionaTipoCliente()
	{ return "selecionaTipoCliente.faces";}
	
	public String cancelar()
	{return "cliente.faces";}
	
	public void MostraMSG(String MSG)
	{
		FacesMessage mesg = new FacesMessage(FacesMessage.SEVERITY_INFO,null,MSG);
		FacesContext.getCurrentInstance().addMessage(null, mesg);
	}
	
	public void MostraERROR(String MSG)
	{
		FacesMessage mesg = new FacesMessage(FacesMessage.SEVERITY_ERROR,null,MSG);
		FacesContext.getCurrentInstance().addMessage(null, mesg);
	}
	
	
	public void editarPrepara(ActionEvent event)
	{
		
	}

	public void setEnderecoEdicao(Endereco enderecoEdicao) {
		this.enderecoEdicao = enderecoEdicao;
	}

	public Endereco getEnderecoEdicao() {
		return enderecoEdicao;
	}
	
	
	public void salvarEndereco(Endereco obj)
	{
		EntityManager em = EntityManagerUtil.getEntityManager();
		EntityTransaction tx = em.getTransaction();
		
		try {
			
			tx.begin();
			em.persist(obj);
			tx.commit();
			
		} catch (Exception e) {
			e.printStackTrace();
			tx.rollback();
		}
		finally
		{
			if(em.isOpen())
			{
				em.close();
			}
		}
	}
	
	
	

	public void setEnderecos(List<Endereco> enderecos) {
		this.enderecos = enderecos;
	}

	public List<Endereco> getEnderecos() {
		return enderecos;
	}  
	
}
Paulo_Silveira

liga o debug do log4j pra gente, pra ver direitinho o que o hibernate diz sobre o estado do objeto. verifique se o id esta realmente preenchido (mas se nao estivesse, deveria ter lancado excessao).

Jr_webmaster_100_jav
log
41463 [http-bio-8080-exec-6] DEBUG org.smartgestor.faces.ClienteFaces  - teste
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.SessionImpl  - Opened session at timestamp: [telefone removido]
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.spi.AbstractTransactionImpl  - begin
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtaining JDBC connection
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtained JDBC connection
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction  - initial autocommit status: true
41465 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction  - disabling autocommit
41472 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Loading entity: [org.smartgestor.cadastro.Cliente#2]
41472 [http-bio-8080-exec-6] DEBUG org.hibernate.SQL  - select cliente0_.codigo as codigo4_1_, cliente0_.celular as celular4_1_, cliente0_.contatoComercial as contatoC3_4_1_, cliente0_.cpfcnpj as cpfcnpj4_1_, cliente0_.dataCadastro as dataCada5_4_1_, cliente0_.dataDeCadastro as dataDeCa6_4_1_, cliente0_.dataNascimento as dataNasc7_4_1_, cliente0_.email as email4_1_, cliente0_.fax as fax4_1_, cliente0_.fone as fone4_1_, cliente0_.inscricaoMunicipal as inscric11_4_1_, cliente0_.limiteDeCredito as limiteD12_4_1_, cliente0_.nomeCompleto as nomeCom13_4_1_, cliente0_.nomeFantasia as nomeFan14_4_1_, cliente0_.observacao as observacao4_1_, cliente0_.rgIE as rgIE4_1_, cliente0_.sitCad as sitCad4_1_, cliente0_.tipoCpfCnpj as tipoCpf18_4_1_, cliente0_.tipoEndereco as tipoEnd19_4_1_, cliente0_.tipoPessoa as tipoPessoa4_1_, cliente0_.vendedor as vendedor4_1_, enderecos1_.ClienteID as ClienteID4_3_, enderecos1_.idEndereco as idEndereco3_, enderecos1_.idEndereco as idEndereco6_0_, enderecos1_.bairro as bairro6_0_, enderecos1_.cep as cep6_0_, enderecos1_.cidade as cidade6_0_, enderecos1_.ClienteID as ClienteID6_0_, enderecos1_.complemento as compleme5_6_0_, enderecos1_.logradouro as logradouro6_0_, enderecos1_.numero as numero6_0_, enderecos1_.tipo as tipo6_0_, enderecos1_.uf as uf6_0_ from cliente cliente0_ left outer join endereco enderecos1_ on cliente0_.codigo=enderecos1_.ClienteID where cliente0_.codigo=?
Hibernate: select cliente0_.codigo as codigo4_1_, cliente0_.celular as celular4_1_, cliente0_.contatoComercial as contatoC3_4_1_, cliente0_.cpfcnpj as cpfcnpj4_1_, cliente0_.dataCadastro as dataCada5_4_1_, cliente0_.dataDeCadastro as dataDeCa6_4_1_, cliente0_.dataNascimento as dataNasc7_4_1_, cliente0_.email as email4_1_, cliente0_.fax as fax4_1_, cliente0_.fone as fone4_1_, cliente0_.inscricaoMunicipal as inscric11_4_1_, cliente0_.limiteDeCredito as limiteD12_4_1_, cliente0_.nomeCompleto as nomeCom13_4_1_, cliente0_.nomeFantasia as nomeFan14_4_1_, cliente0_.observacao as observacao4_1_, cliente0_.rgIE as rgIE4_1_, cliente0_.sitCad as sitCad4_1_, cliente0_.tipoCpfCnpj as tipoCpf18_4_1_, cliente0_.tipoEndereco as tipoEnd19_4_1_, cliente0_.tipoPessoa as tipoPessoa4_1_, cliente0_.vendedor as vendedor4_1_, enderecos1_.ClienteID as ClienteID4_3_, enderecos1_.idEndereco as idEndereco3_, enderecos1_.idEndereco as idEndereco6_0_, enderecos1_.bairro as bairro6_0_, enderecos1_.cep as cep6_0_, enderecos1_.cidade as cidade6_0_, enderecos1_.ClienteID as ClienteID6_0_, enderecos1_.complemento as compleme5_6_0_, enderecos1_.logradouro as logradouro6_0_, enderecos1_.numero as numero6_0_, enderecos1_.tipo as tipo6_0_, enderecos1_.uf as uf6_0_ from cliente cliente0_ left outer join endereco enderecos1_ on cliente0_.codigo=enderecos1_.ClienteID where cliente0_.codigo=?
41474 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 0
41475 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Endereco#1], EntityKey[org.smartgestor.cadastro.Cliente#2]
41476 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Found row of collection: [org.smartgestor.cadastro.Cliente.enderecos#2]
41477 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 1
41477 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Endereco#2], EntityKey[org.smartgestor.cadastro.Cliente#2]
41477 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Found row of collection: [org.smartgestor.cadastro.Cliente.enderecos#2]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Endereco#1]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Endereco#1]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Cliente#2]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Cliente#2]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Endereco#2]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Endereco#2]
41478 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext  - 1 collections were found in result set for role: org.smartgestor.cadastro.Cliente.enderecos
41479 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext  - Collection fully initialized: [org.smartgestor.cadastro.Cliente.enderecos#2]
41479 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.loading.internal.CollectionLoadContext  - 1 collections initialized for role: org.smartgestor.cadastro.Cliente.enderecos
41479 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.StatefulPersistenceContext  - Initializing non-lazy collections
41479 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Done entity load
41494 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.spi.AbstractTransactionImpl  - committing
41495 [http-bio-8080-exec-6] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Processing flush-time cascades
41498 [http-bio-8080-exec-6] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Dirty checking collections
41522 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.Collections  - Collection found: [org.smartgestor.cadastro.Cliente.enderecos#2], was: [org.smartgestor.cadastro.Cliente.enderecos#2] (initialized)
41523 [http-bio-8080-exec-6] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Flushed: 0 insertions, 0 updates, 0 deletions to 3 objects
41523 [http-bio-8080-exec-6] DEBUG org.hibernate.event.internal.AbstractFlushingEventListener  - Flushed: 0 (re)creations, 0 updates, 0 removals to 1 collections
41526 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.util.EntityPrinter  - Listing entities:
41526 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.util.EntityPrinter  - org.smartgestor.cadastro.Cliente{sitCad=0, vendedor=null, fax=null, contatoComercial=null, nomeFantasia=null, rgIE=kj784364, fone=([telefone removido], enderecos=[org.smartgestor.cadastro.Endereco#1, org.smartgestor.cadastro.Endereco#2], observacao=khvim,dknfjh;sklnbjshvfi, tipoEndereco=null, codigo=2, dataDeCadastro=null, limiteDeCredito=574.0, cpfcnpj=[CPF removido], tipoCpfCnpj=null, nomeCompleto=sdfsd, email=sfnnhbvzxndj, dataNascimento=1995-10-04 00:00:00.0, tipoPessoa=F, dataCadastro=2012-05-16 15:33:50.0, celular=([telefone removido], inscricaoMunicipal=null}
41527 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.util.EntityPrinter  - org.smartgestor.cadastro.Endereco{cidade=Madre de Deus, bairro=Centro, complemento=adsfsag, cep=42600-000, uf=BA, cliente=org.smartgestor.cadastro.Cliente#2, tipo=R, idEndereco=1, logradouro=do Dendê, numero=234}
41527 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.util.EntityPrinter  - org.smartgestor.cadastro.Endereco{cidade=Itapissuma, bairro=Centro, complemento=asdasf, cep=53700-000, uf=PE, cliente=org.smartgestor.cadastro.Cliente#2, tipo=AV, idEndereco=2, logradouro=João Pessoa, numero=234}
41527 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction  - committed JDBC Connection
41527 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction  - re-enabling autocommit
41529 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Releasing JDBC connection
41529 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Released JDBC connection
41529 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler  - HHH000163: Logical connection releasing its physical connection
41570 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.SessionImpl  - Opened session at timestamp: [telefone removido]
41571 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtaining JDBC connection
41571 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtained JDBC connection
41572 [http-bio-8080-exec-6] DEBUG org.hibernate.SQL  - select this_.codigo as codigo4_0_, this_.celular as celular4_0_, this_.contatoComercial as contatoC3_4_0_, this_.cpfcnpj as cpfcnpj4_0_, this_.dataCadastro as dataCada5_4_0_, this_.dataDeCadastro as dataDeCa6_4_0_, this_.dataNascimento as dataNasc7_4_0_, this_.email as email4_0_, this_.fax as fax4_0_, this_.fone as fone4_0_, this_.inscricaoMunicipal as inscric11_4_0_, this_.limiteDeCredito as limiteD12_4_0_, this_.nomeCompleto as nomeCom13_4_0_, this_.nomeFantasia as nomeFan14_4_0_, this_.observacao as observacao4_0_, this_.rgIE as rgIE4_0_, this_.sitCad as sitCad4_0_, this_.tipoCpfCnpj as tipoCpf18_4_0_, this_.tipoEndereco as tipoEnd19_4_0_, this_.tipoPessoa as tipoPessoa4_0_, this_.vendedor as vendedor4_0_ from cliente this_ order by this_.codigo asc
Hibernate: select this_.codigo as codigo4_0_, this_.celular as celular4_0_, this_.contatoComercial as contatoC3_4_0_, this_.cpfcnpj as cpfcnpj4_0_, this_.dataCadastro as dataCada5_4_0_, this_.dataDeCadastro as dataDeCa6_4_0_, this_.dataNascimento as dataNasc7_4_0_, this_.email as email4_0_, this_.fax as fax4_0_, this_.fone as fone4_0_, this_.inscricaoMunicipal as inscric11_4_0_, this_.limiteDeCredito as limiteD12_4_0_, this_.nomeCompleto as nomeCom13_4_0_, this_.nomeFantasia as nomeFan14_4_0_, this_.observacao as observacao4_0_, this_.rgIE as rgIE4_0_, this_.sitCad as sitCad4_0_, this_.tipoCpfCnpj as tipoCpf18_4_0_, this_.tipoEndereco as tipoEnd19_4_0_, this_.tipoPessoa as tipoPessoa4_0_, this_.vendedor as vendedor4_0_ from cliente this_ order by this_.codigo asc
41573 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 0
41573 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Cliente#1]
41574 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 1
41575 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Cliente#2]
41575 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Cliente#1]
41576 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Cliente#1]
41576 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Cliente#2]
41577 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Cliente#2]
41577 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.StatefulPersistenceContext  - Initializing non-lazy collections
41577 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Releasing JDBC connection
41582 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Released JDBC connection
41582 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler  - HHH000163: Logical connection releasing its physical connection
41592 [http-bio-8080-exec-6] DEBUG org.hibernate.internal.SessionImpl  - Opened session at timestamp: [telefone removido]
41593 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtaining JDBC connection
41593 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Obtained JDBC connection
41593 [http-bio-8080-exec-6] DEBUG org.hibernate.SQL  - select this_.codigo as codigo4_0_, this_.celular as celular4_0_, this_.contatoComercial as contatoC3_4_0_, this_.cpfcnpj as cpfcnpj4_0_, this_.dataCadastro as dataCada5_4_0_, this_.dataDeCadastro as dataDeCa6_4_0_, this_.dataNascimento as dataNasc7_4_0_, this_.email as email4_0_, this_.fax as fax4_0_, this_.fone as fone4_0_, this_.inscricaoMunicipal as inscric11_4_0_, this_.limiteDeCredito as limiteD12_4_0_, this_.nomeCompleto as nomeCom13_4_0_, this_.nomeFantasia as nomeFan14_4_0_, this_.observacao as observacao4_0_, this_.rgIE as rgIE4_0_, this_.sitCad as sitCad4_0_, this_.tipoCpfCnpj as tipoCpf18_4_0_, this_.tipoEndereco as tipoEnd19_4_0_, this_.tipoPessoa as tipoPessoa4_0_, this_.vendedor as vendedor4_0_ from cliente this_ order by this_.codigo asc
Hibernate: select this_.codigo as codigo4_0_, this_.celular as celular4_0_, this_.contatoComercial as contatoC3_4_0_, this_.cpfcnpj as cpfcnpj4_0_, this_.dataCadastro as dataCada5_4_0_, this_.dataDeCadastro as dataDeCa6_4_0_, this_.dataNascimento as dataNasc7_4_0_, this_.email as email4_0_, this_.fax as fax4_0_, this_.fone as fone4_0_, this_.inscricaoMunicipal as inscric11_4_0_, this_.limiteDeCredito as limiteD12_4_0_, this_.nomeCompleto as nomeCom13_4_0_, this_.nomeFantasia as nomeFan14_4_0_, this_.observacao as observacao4_0_, this_.rgIE as rgIE4_0_, this_.sitCad as sitCad4_0_, this_.tipoCpfCnpj as tipoCpf18_4_0_, this_.tipoEndereco as tipoEnd19_4_0_, this_.tipoPessoa as tipoPessoa4_0_, this_.vendedor as vendedor4_0_ from cliente this_ order by this_.codigo asc
41595 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 0
41596 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Cliente#1]
41596 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result set row: 1
41597 [http-bio-8080-exec-6] DEBUG org.hibernate.loader.Loader  - Result row: EntityKey[org.smartgestor.cadastro.Cliente#2]
41597 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Cliente#1]
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Cliente#1]
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Resolving associations for [org.smartgestor.cadastro.Cliente#2]
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.TwoPhaseLoad  - Done materializing entity [org.smartgestor.cadastro.Cliente#2]
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.internal.StatefulPersistenceContext  - Initializing non-lazy collections
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Releasing JDBC connection
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.LogicalConnectionImpl  - Released JDBC connection
41598 [http-bio-8080-exec-6] DEBUG org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler  - HHH000163: Logical connection releasing its physical connection
Criado 15 de maio de 2012
Ultima resposta 16 de mai. de 2012
Respostas 6
Participantes 4