org.hibernate.hql.internal.ast.querysyntaxexception: bse_clientcontact not mapped [select cc bse_clientcontact cc cc.clientid=:id].
1.model class
package com.si.bse.model; @entity @table(name = "bse_clientcontact", uniqueconstraints = { @uniqueconstraint(columnnames = "id")}) public class clientcontact { @id @generatedvalue(strategy = generationtype.auto) @column(name="id", unique=true, nullable=false) @notnull private long clientcontactid; @column(name = "clientcontactname", nullable = false) @notnull @notempty private string clientcontactname; @column(name = "clientcontactnumber", nullable = false) @notempty @size(min = 10, max = 10) private string clientcontactnumber; @manytoone @joincolumn(name="client_id") private client client; public clientcontact(){} public long getclientcontactid() { return clientcontactid; } public void setclientcontactid(long clientcontactid) { this.clientcontactid = clientcontactid; } public string getclientcontactname() { return clientcontactname; } public void setclientcontactname(string clientcontactname) { this.clientcontactname = clientcontactname; } public string getclientcontactnumber() { return clientcontactnumber; } public void setclientcontactnumber(string clientcontactnumber) { this.clientcontactnumber = clientcontactnumber; } public client getclient() { return client; } public void setclient(client client) { this.client = client; }
}
2.dao implation
@suppresswarnings("unchecked") @transactional @override public client getclientlistdetail(long id) { //session session = sessionfactory.opensession(); client clientlist = (client) getcurrentsession().load(client.class, id); return clientlist; } @override @transactional public clientcontact getclientcontact(long id) { //session session = sessionfactory.opensession(); clientcontact clientcontactlist = (clientcontact) getcurrentsession().createquery("select cc bse_clientcontact cc cc.clientid=:id").setparameter("id", id).uniqueresult(); return clientcontactlist; }
3.controller
@requestmapping(value = "singleview.do") public string navigatetoproductview( map<string,object>map) { /* if(result.haserrors()){ modelandview model1=new modelandview("add"); return model1; }*/ int clientid=13;// integer.parseint(id); system.out.println("it controller..single view"); client clientlist = searchservices.getclientlistdetail(clientid); clientcontact clientcontact = searchservices.getclientcontact(clientid); // clientimage clientimage = searchservices.getclientimage(clientid); //clientvideo clientvideo = searchservices.getclientvideo(clientid); clientcategory clientcategory = searchservices.getclientcategory(clientid); //system.out.println(clientlist.getclientid()); //system.out.println(clientlist.getclientname()); map.put("clientlist", clientlist); map.put("clientcontact", clientcontact); // map.put("clientimage", clientimage); //map.put("clientvideo", clientvideo); map.put("clientcategory", clientcategory); system.out.println("single view....."); system.out.println("id----:"+clientid); map.put("popularsearchlist", popularsearchservices.getpopularsearchlist()); return "singleproductview"; }
4.this error
severe: servlet.service() servlet [appservlet] in context path [/bse] threw exception [request processing failed; nested exception org.hibernate.hql.internal.ast.querysyntaxexception: bse_clientcontact not mapped [select cc bse_clientcontact cc cc.clientid=:id]] root cause org.hibernate.hql.internal.ast.querysyntaxexception: bse_clientcontact not mapped @ org.hibernate.hql.internal.ast.util.sessionfactoryhelper.requireclasspersister(sessionfactoryhelper.java:189) @ org.hibernate.hql.internal.ast.tree.fromelementfactory.addfromelement(fromelementfactory.java:109) @ org.hibernate.hql.internal.ast.tree.fromclause.addfromelement(fromclause.java:95) @ org.hibernate.hql.internal.ast.hqlsqlwalker.createfromelement(hqlsqlwalker.java:331) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.fromelement(hqlsqlbasewalker.java:3633) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.fromelementlist(hqlsqlbasewalker.java:3522) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.fromclause(hqlsqlbasewalker.java:706) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.query(hqlsqlbasewalker.java:562) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.selectstatement(hqlsqlbasewalker.java:299) @ org.hibernate.hql.internal.antlr.hqlsqlbasewalker.statement(hqlsqlbasewalker.java:247) @ org.hibernate.hql.internal.ast.querytranslatorimpl.analyze(querytranslatorimpl.java:278) @ org.hibernate.hql.internal.ast.querytranslatorimpl.docompile(querytranslatorimpl.java:206) @ org.hibernate.hql.internal.ast.querytranslatorimpl.compile(querytranslatorimpl.java:158) @ org.hibernate.engine.query.spi.hqlqueryplan.(hqlqueryplan.java:126) @ org.hibernate.engine.query.spi.hqlqueryplan.(hqlqueryplan.java:88) @ org.hibernate.engine.query.spi.queryplancache.gethqlqueryplan(queryplancache.java:190) @ org.hibernate.internal.abstractsessionimpl.gethqlqueryplan(abstractsessionimpl.java:301) @ org.hibernate.internal.abstractsessionimpl.createquery(abstractsessionimpl.java:236) @ org.hibernate.internal.sessionimpl.createquery(sessionimpl.java:1800) @ com.si.bse.dao.impl.searchdaoimpl.getclientcontact(searchdaoimpl.java:123) @ com.si.bse.services.impl.searchservicesimpl.getclientcontact(searchservicesimpl.java:44) @ com.si.bse.controller.searchcontroller.navigatetoproductview(searchcontroller.java:110) @ 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)
try
select cc clientcontact cc cc.clientcontactid= :id
please note when use jpql or hql, dealing entities, not tables, should select
clientcontact
entity , not table bse_clientcontact
mapped.
Comments
Post a Comment