Sera Mapeamento

0 respostas
V
Bom dia Galera,

Estou a 3 dias tentando achar uma solução para o seguinte problema.

Na inserção, qdo. o banco esta vazio ele grava apenas na tabela TipoCombustivel, na px. inserção ele grava nas duas tabelas porem o id da tabela idiomaTipoCombustivel grava o id anterior da tabela TipoCombustivel.

Caso alguem visualize o erro, favor me informar pois ate agora não consegui encontrar o erro.

Desde ja agradeço pela atenção de todos.

Tenho uma classe TipoCombustivel, outra IdiomaTipoCombustivel e uma Idioma

@Entity

@Table(name = TIPO_COMBUSTIVEL)

@SequenceGenerator(name = SQ_TICO_SQ_ID, sequenceName = SQ_TICO_SQ_ID)

public class TipoCombustivel extends FwjBaseEntidade{
private static final long serialVersionUID = 6450749796843273314L;

private Long id;
protected Long versao;
private Long classe;
private Boolean ativo;
//private Set<IdiomaTipoCombustivel> nomes = new HashSet<IdiomaTipoCombustivel>();
//private Map<Idioma, IdiomaTipoCombustivel> nomes = new HashMap<Idioma, IdiomaTipoCombustivel>();
private List<IdiomaTipoCombustivel>nomes = new ArrayList<IdiomaTipoCombustivel>();

public TipoCombustivel() {
}

public TipoCombustivel(Long id, Long versao, Long classe, Boolean ativo) {
	this.id = id;
	this.versao = versao;
	this.classe = classe;
	this.ativo = ativo;
}

@Id
@Column(name = "TICO_SQ_ID", unique = true, nullable = false, precision = 10, scale = 0)
@GeneratedValue(generator = "SQ_TICO_SQ_ID", strategy = GenerationType.SEQUENCE)
public Long getId() {
	return this.id;
}

public void setId(Long id) {
	this.id = id;
}

/**
* Criado em 11/12/2007
* @author A7F4
* O m&#65533;todo <b>equals</b> proporciona as funcionalidades de ... para ...
* TODO concluir descri&#65533;&#65533;o
* 
* Mais detalhes em @see java.lang.Object#equals(java.lang.Object)
* <p></p>
* @param obj
* @return
*/

@Override
public boolean equals(Object obj) {
	if(obj instanceof TipoCombustivel){
		TipoCombustivel that = (TipoCombustivel)obj;
		return (this.getId().equals(that.getId()));
	}
	return false;
}

public class IncluirTipoCombustivelAcao extends TemplateIncluirAcao<TipoCombustivelDetalheBean, TipoCombustivel>{

public static final String BEAN_NAME = Fwj.getInstance().getFabrica().getJSF().getBeanName(IncluirTipoCombustivelAcao.class);
@SuppressWarnings("unchecked")
@Override
public List gerarListaBusca() throws FwjSystemException, FwjBusinessException {
	// TODO Auto-generated method stub
	return null;
}

@Override
public void limparTela() {
	TipoCombustivelDetalheBean bean = (TipoCombustivelDetalheBean)this.getPaginaBean();
	bean.resetaDetalhe();
}

/* (non-Javadoc)
 * @see br.com.petrobras.sigea.ext.web.template.acoes.TemplateIncluirAcao#executar()
 */
//@Override
public String executar() throws FwjSystemException {
	return super.executar();
}

@SuppressWarnings("unchecked")
public void preExecucao()throws FwjSystemException, FwjBusinessException {		
	this.getCacheSessao().setMensagemExcecao(null);				
	TipoCombustivelDetalheBean bean = (TipoCombustivelDetalheBean) this.getPaginaBean();
	this.getPaginaBean().setEntidade(bean.preencheparamentros((TipoCombustivelDetalheBean)this.getPaginaBean()));	
	
	if(!bean.validaCampos()){
		//Fwj.getInstance().getFabrica().getJSF().addErrorMessage("fwj_erro_campos_obrigatorios");
		throw new FwjBusinessException("fwj_erro_campos_obrigatorios");
	}
			
	
	
		
	
}

}

/**
* Criado em 11/12/2007
* @author A7F4
* O m&#65533;todo <b>hashCode</b> proporciona as funcionalidades de ... para ...
* TODO concluir descri&#65533;&#65533;o
* 
* Mais detalhes em @see java.lang.Object#hashCode()
* <p></p>
* @return
*/

@Override
public int hashCode() {
    int result = 17;
    
    result = 37 * result + ( getId() == null ? 0 : this.getId().hashCode() );
    return result;

}

@Version
@Column(name = "TICO_CD_VERSAO")
protected Long getVersao() {
	return this.versao;
}

protected void setVersao(Long versao) {
	this.versao = versao;
}

@Column(name = "TICO_IN_CLASSE", nullable = false, precision = 1, scale = 0)	
public Long getClasse() {
	return this.classe;
}

public void setClasse(Long classe) {
	this.classe = classe;
}

@Column(name = "TICO_IN_SITUACAO", nullable = false, precision = 1, scale = 0)
public Boolean isAtivo() {
	return this.ativo;
}

public void setAtivo(Boolean ativo) {
	this.ativo = ativo;
}
/*

@OneToMany(cascade = CascadeType.ALL,  mappedBy = tipoCombustivel)

@MapKey(name = idioma)

public Map<Idioma, IdiomaTipoCombustivel> getNomes() {

return this.nomes;

}
public void setNomes(Map<Idioma, IdiomaTipoCombustivel> nomes) {
	this.nomes = nomes;
}
<em>/

<a class="mention" href="/u/override">@Override</a>

public String mostraChaveFormatada() {

return “TICO_SQ_ID:” + this.getId();

}

/</em>

@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = “tipoCombustivel”)

@MapKey(name = “idioma”)

public Set getNomes() {

return nomes;

}
public void setNomes(Set<IdiomaTipoCombustivel> nomes) {
	this.nomes = nomes;
}
*/
@OneToMany(cascade = CascadeType.ALL, mappedBy = "tipoCombustivel")
public List<IdiomaTipoCombustivel> getNomes() {
	return nomes;
}

public void setNomes(List<IdiomaTipoCombustivel> nomes) {
	this.nomes = nomes;
}

}

Criado 13 de fevereiro de 2008
Respostas 0
Participantes 1