Witam, nie znalazlem nigdzie interesujacej odpowiedzi, wiec zakladam nowy watek.
Stworzyłem nowy projekt WebApplication z JSF i Hibernate. Następnie stworzylem klase HibernateUtil. Pozniej stworzylem baze w derby i tabele.
nastepnie stworzylem encje i klasy na bazie tabel, pozniej mapowanie w xml'u i po napisanu panelu uzytkownika przgladarka przy probie dodania rekordu do tabeli wyrzuca mi bląd: org.hibernate.hql.ast.QuerySyntaxException: prac is not mapped [from prac]. Możecie doradzic co zrobilem zle bo juz mi rece opdaja.
0
0
A czy te klasy encyjne są ładnie anotowane przez @Entity i są skonfigurowane w konfiguracji hibernate?
0
Masz błąd w zapytaniu (query). Wygląda na to, że chcesz znaleźć coś w tabeli, której nie masz zmapowanej i/lub literówka/błąd składni
0
Klasa encyjna mysle ze jest dobrze wykonana, wszystko domyslnie prze netbeans.
@Entity
@Table(name = "PRAC")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Prac.findAll", query = "SELECT p FROM Prac p"),
@NamedQuery(name = "Prac.findById", query = "SELECT p FROM Prac p WHERE p.id = :id"),
@NamedQuery(name = "Prac.findByImie", query = "SELECT p FROM Prac p WHERE p.imie = :imie"),
@NamedQuery(name = "Prac.findByNazwisko", query = "SELECT p FROM Prac p WHERE p.nazwisko = :nazwisko"),
@NamedQuery(name = "Prac.findByStaz", query = "SELECT p FROM Prac p WHERE p.staz = :staz"),
@NamedQuery(name = "Prac.findByPensja", query = "SELECT p FROM Prac p WHERE p.pensja = :pensja")})
public class Prac implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "ID")
private Integer id;
@Size(max = 30)
@Column(name = "IMIE")
private String imie;
@Size(max = 30)
@Column(name = "NAZWISKO")
private String nazwisko;
@Column(name = "STAZ")
private Integer staz;
@Column(name = "PENSJA")
private Integer pensja;
public Prac() {
}
public Prac(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getImie() {
return imie;
}
public void setImie(String imie) {
this.imie = imie;
}
public String getNazwisko() {
return nazwisko;
}
public void setNazwisko(String nazwisko) {
this.nazwisko = nazwisko;
}
public Integer getStaz() {
return staz;
}
public void setStaz(Integer staz) {
this.staz = staz;
}
public Integer getPensja() {
return pensja;
}
public void setPensja(Integer pensja) {
this.pensja = pensja;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.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 Prac)) {
return false;
}
Prac other = (Prac) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "def.Prac[ id=" + id + " ]";
}
}
0
W hibernate.cfg.xml encja jest zmapowana?
<mapping class="***.Prac" /> ?