org.hibernate.hql.internal.ast.QuerySyntaxException:bse_clientcontact未映射[從bse_clientcontact cc選擇cc,其中cc.clientId =:id]。rg.hibernate.hql.internal.ast.QuerySyntaxException:bse_clientcontact未映射
1.型號類
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 from bse_clientcontact cc where 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 is 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,本是誤差
SEVERE:servlet [appServlet]與path [/ bse]上下文中的Servlet.service()拋出異常[Request processing failed;嵌套異常是org.hibernate.hql.internal.ast.QuerySyntaxException:bse_clientcontact未映射[根據bse_clientcontact cc選擇cc,其中cc.clientId =:id]]具有根本原因 org.hibernate.hql.internal.ast.QuerySyntaxException: bse_clientcontact未映射 at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:189) at 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) at org.hibernate.hql.i norg.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:706) at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker。查詢(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) 在有機hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:158) at org.hibernate.eng (HQLQueryPlan.java:126) at org.hibernate.engine.query.spi.HQLQueryPlan。(HQLQueryPlan.java:88) at 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) at com.si.bse.dao.impl.SearchDaoImpl.getClientContact(SearchDaoImpl.java:123) at com.si.bse.services.impl.SearchServicesImpl.getClientContact( SearchServicesImpl.java:44) at com.si.bse.controller.Searchcontroller.navigateToProductView(Searchcontroller.java:110) 在sun.reflect.NativeMethodAccessorImpl.invoke0(本機方法) 在sun.reflect.NativeMethodAccessorImpl.invoke(來源不明) 在sun.reflect.DelegatingMethodAccessorImpl.invoke(來源不明) 在java.lang.reflect.Method中。調用(來源不明)
先生,我仍然收到錯誤CLIENTCONTACT未映射.. :( –
謝謝...我得到了解決方案.. :) –
問題是什麼? –