Erro de mapeamento.AJUDA

9 respostas
A

Olá pessoa estou com um erro aqui.E gostaria da ajuda de vcs.O que vcs acham que poderia ser?

Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.

Exception Details: org.hibernate.QueryException
could not resolve property: NaturezasAcao of: br.com.sistemajuridicowar.model.TiposAcao [SELECT t.idTiposAcao, t.descricao,t.flagAtivo, n.descricao FROM br.com.sistemajuridicowar.model.TiposAcao t JOIN t.NaturezasAcao n ]

Possible Source of Error:
Class Name: org.hibernate.persister.entity.AbstractPropertyMapping
File Name: AbstractPropertyMapping.java
Method Name: propertyException
Line Number: 44

Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.

9 Respostas

zoren

Coloca sua classe TiposAcao e NaturezasAcao

A

package br.com.sistemajuridicowar.model;

import java.io.Serializable;
import javax.persistence.*;

/**
*

  • @author Administrator
    */
    @Entity
    @Table(name = “tipos_acao”)
    @NamedQueries({@NamedQuery(name = “TiposAcao.findAll”, query =“SELECT t FROM TiposAcao t WHERE t.idTiposAcao = :idTiposAcao”)})
public class TiposAcao implements Serializable {

private static final long serialVersionUID = 1L;

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

<a class="mention" href="/u/basic">@Basic</a>(optional = false)

@Column(name = “idTipos_Acao”,nullable = false)

private Integer idTiposAcao;

<a class="mention" href="/u/basic">@Basic</a>(optional = false)

@Column(name = “Descricao”,nullable = false)

private String descricao;

@Column(name = “Flag_Ativo”)

private Character flagAtivo;

@JoinColumn(name = “idNaturezas_Acao”, referencedColumnName = “idNaturezas_Acao”)

@ManyToOne(fetch = FetchType.EAGER)

private NaturezasAcao idNaturezasAcao;
public TiposAcao() {
}

public TiposAcao(Integer idTiposAcao) {
    this.idTiposAcao = idTiposAcao;
}

public TiposAcao(Integer idTiposAcao, String descricao) {
    this.idTiposAcao = idTiposAcao;
    this.descricao = descricao;
}

public Integer getIdTiposAcao() {
    return idTiposAcao;
}

public void setIdTiposAcao(Integer idTiposAcao) {
    this.idTiposAcao = idTiposAcao;
}

public String getDescricao() {
    return descricao;
}

public void setDescricao(String descricao) {
    this.descricao = descricao;
}

public Character getFlagAtivo() {
    return flagAtivo;
}

public void setFlagAtivo(Character flagAtivo) {
    this.flagAtivo = flagAtivo;
}


public NaturezasAcao getIdNaturezasAcao() {
    return idNaturezasAcao;
}

public void setIdNaturezasAcao(NaturezasAcao idNaturezasAcao) {
    this.idNaturezasAcao = idNaturezasAcao;
}

@Override
public int hashCode() {
    int hash = 0;
    hash += (idTiposAcao != null ? idTiposAcao.hashCode() : 0);
    return hash;
}

@Override
public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof TiposAcao)) {
        return false;
    }
    TiposAcao other = (TiposAcao) object;
    if ((this.idTiposAcao == null && other.idTiposAcao != null) || (this.idTiposAcao != null && !this.idTiposAcao.equals(other.idTiposAcao))) {
        return false;
    }
    return true;
}

@Override
public String toString() {
    return "br.com.sistemajuridicowar.model.TiposAcao[idTiposAcao=" + idTiposAcao + "]";
}

}

/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

package br.com.sistemajuridicowar.model;

import java.io.Serializable;

import java.util.Collection;

import javax.persistence.Basic;

import javax.persistence.CascadeType;

import javax.persistence.Column;

import javax.persistence.Entity;

import javax.persistence.FetchType;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType;

import javax.persistence.Id;

import javax.persistence.NamedQueries;

import javax.persistence.NamedQuery;

import javax.persistence.OneToMany;

import javax.persistence.Table;

/**
*

  • @author Administrator
    
    */
    
    @Entity
    
    @Table(name = naturezas_acao)
    
    @NamedQueries({@NamedQuery(name = NaturezasAcao.findAll, query = SELECT n FROM NaturezasAcao n), @NamedQuery(name = NaturezasAcao.findByIdNaturezasAcao, query = SELECT n FROM NaturezasAcao n WHERE n.idNaturezasAcao = :idNaturezasAcao), @NamedQuery(name = NaturezasAcao.findByDescricao, query = SELECT n FROM NaturezasAcao n WHERE n.descricao = :descricao), @NamedQuery(name = NaturezasAcao.findByFlagAtivo, query = SELECT n FROM NaturezasAcao n WHERE n.flagAtivo = :flagAtivo)})
    
    public class NaturezasAcao implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    
    <a class="mention" href="/u/basic">@Basic</a>(optional = false)
    
    @Column(name = “idNaturezas_Acao”,nullable = false)
    
    private Integer idNaturezasAcao;
    
    <a class="mention" href="/u/basic">@Basic</a>(optional = false)
    
    @Column(name = “Descricao”,nullable = false)
    
    private String descricao;
    
    @Column(name = “Flag_Ativo”)
    
    private Character flagAtivo;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = “idNaturezasAcao”, fetch = FetchType.LAZY)
    
    private Collection tiposAcaoCollection;
    

    public NaturezasAcao() {
    }

    public NaturezasAcao(Integer idNaturezasAcao) {
    
    this.idNaturezasAcao = idNaturezasAcao;
    
    }
    
    public NaturezasAcao(Integer idNaturezasAcao, String descricao) {
    
    this.idNaturezasAcao = idNaturezasAcao;
    
    this.descricao = descricao;
    
    }
    
    public Integer getIdNaturezasAcao() {
    
    return idNaturezasAcao;
    
    }
    
    public void setIdNaturezasAcao(Integer idNaturezasAcao) {
    
    this.idNaturezasAcao = idNaturezasAcao;
    
    }
    
    public String getDescricao() {
    
    return descricao;
    
    }
    
    public void setDescricao(String descricao) {
    
    this.descricao = descricao;
    
    }
    
    public Character getFlagAtivo() {
    
    return flagAtivo;
    
    }
    
    public void setFlagAtivo(Character flagAtivo) {
    
    this.flagAtivo = flagAtivo;
    
    }
    
    public Collection getTiposAcaoCollection() {
    
    return tiposAcaoCollection;
    
    }
    
    public void setTiposAcaoCollection(Collection tiposAcaoCollection) {
    
    this.tiposAcaoCollection = tiposAcaoCollection;
    
    }
    
    <a class="mention" href="/u/override">@Override</a>
    
    public int hashCode() {
    
    int hash = 0;
    
    hash += (idNaturezasAcao != null ? idNaturezasAcao.hashCode() : 0);
    
    return hash;
    
    }
    
    <a class="mention" href="/u/override">@Override</a>
    
    public boolean equals(Object object) {
    
    // TODO: Warning - this method won’t work in the case the id fields are not set
    
    if (!(object instanceof NaturezasAcao)) {
    
    return false;
    
    }
    
    NaturezasAcao other = (NaturezasAcao) object;
    
    if ((this.idNaturezasAcao == null && other.idNaturezasAcao != null) || (this.idNaturezasAcao != null && !this.idNaturezasAcao.equals(other.idNaturezasAcao))) {
    
    return false;
    
    }
    
    return true;
    
    }
    
    <a class="mention" href="/u/override">@Override</a>
    
    public String toString() {
    
    return “br.com.sistemajuridicowar.model.NaturezasAcao[idNaturezasAcao=” + idNaturezasAcao + “]”;
    
    }
    

}

A

o ERRO DEVE ESTAR EM ALGUM LUGAR AQUI…

public List todosTiposAcao() {

return tiposAcaoDao.pesq(SELECT t.idTiposAcao, t.descricao,t.flagAtivo, n.descricao FROM +

" TiposAcao t JOIN t.NaturezasAcao n ").getResultList();
}
zoren

Desculpa a demora

o erro é nessa query mesmo, n tenho certeza, mais essa parte

JOIN t.NaturezasAcao

está meio estranha, nunca vi algo assim

essa query deve estar errada

SELECT t.idTiposAcao, t.descricao,t.flagAtivo, n.descricao FROM TiposAcao t JOIN t.NaturezasAcao n

Acho que seria assim a sua query

SELECT t.idTiposAcao, t.descricao,t.flagAtivo, n.descricao FROM TiposAcao t JOIN NaturezaAcao n ON t.idNaturezaAcao = n.tiposAcaoCollection

[edit:]
Não olhei direito, é bem capaz que de algum erro por usar algum campo de maneira errada

o seu erro foi na hora de fazer o JOIN

A

Ola.Vou tentar. E obrigado por estar ajudando .vc tem msn?

zoren

Tenho, mas n uso muito, falta de tempo

A

Ola.Agora deu este problema oq podera ser?

Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.

Exception Details: java.lang.NoSuchMethodError
org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V

Possible Source of Error:
Class Name: org.hibernate.hql.antlr.HqlBaseParser
File Name: HqlBaseParser.java
Method Name: fromJoin
Line Number: 1802

Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.

zoren

Deve ter dado outro erro na query, coloca ela de novo aqui

A

OLa novamente.Primeiramente muito obrigado.Agradeço muito mesmo.Vc esta ajudando muito.Mas vamos lá…O erro podera esta nesta funcao. Esta funcao é responsavel por pegar as informacoes daquela select q vc me passou e tacar em uma lista q sera usado para um table Woodtock para mostrar os valores.

[b]
public void todosTiposAcoes(){

ArrayList<TiposAcoesBean> tipAcoes  = new ArrayList<TiposAcoesBean>();

    List todosTipAcoes = getTiposAcaoFacade().todosTiposAcao();

    for (Iterator iter = todosTipAcoes.iterator(); iter.hasNext();){
        Object[] o = (Object[]) iter.next();
        tipAcoes.add(new TiposAcoesBean((Integer) o[0],(String) o[1],(String) o[2],(Character) o[3]));
    }

    tiposAcoes = (TiposAcoesBean[]) tipAcoes.toArray(new TiposAcoesBean[0]);

}
[/b]

/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

package br.com.sistemajuridicowar.bean;

import java.io.Serializable;

/**
*

  • @author Andrei
    
    */
    
    public class TiposAcoesBean implements Serializable {
    
    private Integer idTiposAcao;
    
    private String descricao;
    
    private String naturezasAcao;
    
    private Character flagAtivo;
    
    public TiposAcoesBean(Integer idTiposAcao,String descricao, String naturezasAcao, Character flagAtivo) {
    
    this.idTiposAcao = idTiposAcao;
    
    this.descricao = descricao;
    
    this.naturezasAcao = naturezasAcao;
    
    this.flagAtivo = flagAtivo;
    
    }
    

    public TiposAcoesBean() {
    }

    public Integer getIdTiposAcao() {
    
    return idTiposAcao;
    
    }
    
    public void setIdTiposAcao(Integer idTiposAcao) {
    
    this.idTiposAcao = idTiposAcao;
    
    }
    
    public String getDescricao() {
    
    return descricao;
    
    }
    
    public void setDescricao(String descricao) {
    
    this.descricao = descricao;
    
    }
    
    public Character getFlagAtivo() {
    
    return flagAtivo;
    
    }
    
    public void setFlagAtivo(Character flagAtivo) {
    
    this.flagAtivo = flagAtivo;
    
    }
    
    public String getNaturezasAcao() {
    
    return naturezasAcao;
    
    }
    
    public void setNaturezasAcao(String naturezasAcao) {
    
    this.naturezasAcao = naturezasAcao;
    
    }
    

}

Criado 11 de setembro de 2009
Ultima resposta 13 de set. de 2009
Respostas 9
Participantes 2