Hallo Zusamnnen,
die Zeile
Quote:
Iterator i = HibernateUtil.getCurrentSession().createQuery("from svs where leistung_id = " + curLeistung.getId() + " order by datum desc").list().iterator();
erzeugt folgende Fehlermeldung. Warum und wie kann ich das beheben?!
zu erst meine Fehlermeldung dann die involvierten Klassen:
Quote:
org.hibernate.hql.ast.QuerySyntaxException: svs is not mapped [from svs where leistung_id = 2 order by datum desc]
org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)
org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:255)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3056)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2945)
org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:228)
org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:160)
org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:77)
org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
referenzProjekt.controller.organisation.OrganisationController.getLeistungSelectionList(OrganisationController.java:428)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
org.apache.myfaces.el.PropertyResolverImpl.getProperty(PropertyResolverImpl.java:457)
org.apache.myfaces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:85)
org.apache.myfaces.el.ELParserHelper$MyPropertySuffix.evaluate(ELParserHelper.java:535)
org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145)
org.apache.myfaces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:386)
javax.faces.component.UIData.getValue(UIData.java:1023)
javax.faces.component.UIData.createDataModel(UIData.java:789)
javax.faces.component.UIData.getDataModel(UIData.java:769)
javax.faces.component.UIData.getRowCount(UIData.java:194)
org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeInnerHtml(HtmlTableRendererBase.java:221)
org.apache.myfaces.shared_impl.renderkit.html.HtmlTableRendererBase.encodeChildren(HtmlTableRendererBase.java:134)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:282)
org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:262)
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:199)
org.richfaces.renderkit.html.PanelRenderer.doEncodeChildren(PanelRenderer.java:194)
org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:121)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:527)
javax.faces.webapp.UIComponentTag.encodeChildren(UIComponentTag.java:483)
javax.faces.webapp.UIComponentTag.doEndTag(UIComponentTag.java:364)
org.apache.jsp.referenzprojekt.organisation.eingabe_jsp._jspx_meth_rich_005fpanel_005f0(eingabe_jsp.java:406)
org.apache.jsp.referenzprojekt.organisation.eingabe_jsp._jspx_meth_h_005fform_005f0(eingabe_jsp.java:237)
org.apache.jsp.referenzprojekt.organisation.eingabe_jsp._jspx_meth_f_005fview_005f0(eingabe_jsp.java:179)
org.apache.jsp.referenzprojekt.organisation.eingabe_jsp._jspService(eingabe_jsp.java:144)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:419)
org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:211)
org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
prozessManager.web.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:29)
Hier ein Auszug aus meine Leistungsklasse:
Code:
package referenzProjekt.domain.leistung;
import ...
@Entity
@Table(name = "leistung")
public class Leistung {
private Long id;
private String name;
....
private Set<SVS> svsSet = new LinkedHashSet<SVS>();
....
private Organisation organisation;
....
public Leistung() {
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@OneToMany(mappedBy="leistung",cascade=CascadeType.ALL,fetch=FetchType.EAGER)
public Set<SVS> getSvsSet() {
return svsSet;
}
public void setSvsSet(Set<SVS> svsSet) {
this.svsSet = svsSet;
}
public void svsZuweisen(SVS svs){
this.svsSet.add(svs);
svs.setLeistung(this);
}
public void svsEntfernen(SVS svs){
this.svsSet.remove(svs);
svs.setLeistung(null);
}
@ManyToOne()
@JoinColumn()
public Organisation getOrganisation() {
return organisation;
}
public void setOrganisation(Organisation organisation) {
this.organisation = organisation;
}
}
Hier ein Auszug aus meiner SVS Klasse
Code:
package referenzProjekt.domain.svs;
import ....
@Entity
@Table(name = "svs")
public class SVS {
private double wert;
private Date datum;
private Long id;
private Leistung leistung;
private User autor;
public SVS() {
}
public SVS(User autor) {
this.autor = autor;
}
@ManyToOne(cascade = { CascadeType.MERGE })
@JoinColumn(nullable = false)
public User getAutor() {
return autor;
}
public void setAutor(User autor) {
this.autor = autor;
}
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public double getWert() {
return wert;
}
public void setWert(double wert) {
this.wert = wert;
}
public Date getDatum() {
return datum;
}
public void setDatum(Date datum) {
this.datum = datum;
}
@ManyToOne
@JoinColumn()
public Leistung getLeistung() {
return leistung;
}
public void setLeistung(Leistung leistung) {
this.leistung = leistung;
}
}
Hier der OrganisationsController der die fehlerhafte Methode aufruft
Code:
....
public class OrganisationController extends RefController {
....
public List<LeistungSelection> getLeistungSelectionList() {
List <LeistungSelection> selectionList = new LinkedList<LeistungSelection>();
Set <Leistung> leistungList = this.organisation.getLeistungSet();
Iterator iterator = leistungList.iterator();
Long counter = new Long(1);
while (iterator.hasNext()){
Leistung curLeistung = (Leistung)iterator.next();
LeistungSelection selection = new LeistungSelection(curLeistung);
Iterator i = HibernateUtil.getCurrentSession().createQuery("from svs where leistung_id = " + curLeistung.getId() + " order by datum desc").list
[i][u][b]DIESE ZEILE ERZEUGT DIE FEHLERMELDUNG[/b][/u][/i]
().iterator();
if (i.hasNext()){
SVS aktuellerSVS = (SVS)i.next();
selection.setAktuellerSVS(aktuellerSVS);
}
selection.setListKey(counter);
selectionList.add(selection);
counter++;
}
return selectionList;
}
....
}
[/quote]
Quote: