-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Error retrieve: Unable to map the database table.
PostPosted: Sun Mar 08, 2009 5:02 am 
Newbie

Joined: Sun Mar 08, 2009 4:33 am
Posts: 2
Greetings,
i'm using the Hibernate with Spring framework for my school project. I'm able to use the hibernate to enter data into the database. The snippet of the codes are shown below for inserting records into the database:

Code:
DataBean dataBean = new DataBean();
dataBean.setDteSent(aujourd_hui);
dataBean.setStatut(emauxStatus);
getHibernateTemplate().save(dataBean);


I want to retrieve the records but it gives an error the database table is not map

Code:
Details details = new Details();
obj = getHibernateTemplate().find("from MAILBOX where status= P");
for (Iterator i = obj.iterator();i.hasNext();)
      {
         details = (Details)i.next();   
      }
      emauxDetailsList.add(details);


I do not know why i'm not able to retrieve the records but able to insert the records into the database. Where have i missed?

Hibernate version:
Hibernate version i'm using is 3.1.2 with the Spring Framework

Mapping documents:
Code:
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<!-- DO NOT EDIT: This is a generated file that is synchronized -->
<!-- by MyEclipse Hibernate tool integration.                   -->
<!-- Created Thu Aug 03 17:12:18 SGT 2006                         -->
<hibernate-mapping>

    <class name="com.dao.model.EmauxDaoBean" table="graffiti.MAILBOX">
        <id name="mailOid" column="mail_oid" type="java.lang.Integer">
            <generator class="assigned"/>
        </id>

        <property name="type" column="type" type="java.lang.String" />
        <property name="dteSent" column="dteSent" type="java.util.Date" />
        <property name="dteAdded" column="dteAdded" type="java.util.Date" />
        <property name="nom_d_utilisateur" column="userName" type="java.lang.String" />
        <property name="statut" column="status" type="java.lang.String"/>
        <property name="adresse" column="address" type="java.lang.String"/>
       
    </class>
   
</hibernate-mapping>


Full stack trace of any exception that occurs:
Code:
16:27:17,940 INFO  [XmlBeanDefinitionReader] Loading XML bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml]
16:27:18,043 INFO  [SQLErrorCodesFactory] SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
16:27:18,656 INFO  [STDOUT] org.springframework.orm.hibernate3.HibernateQueryException: graffiti.MAILBOX is not mapped. [from graffiti.MAILBOX where status= P]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: graffiti.MAILBOX is not mapped. [from graffiti.MAILBOX where status= P]
16:27:18,707 INFO  [STDOUT] org.hibernate.hql.ast.QuerySyntaxException: graffiti.MAILBOX is not mapped. [from graffiti.MAILBOX where status= P]
        at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:157)
        at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:86)
        at org.hibernate.hql.ast.tree.FromClause.addFromElement(FromClause.java:70)
        at org.hibernate.hql.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:263)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3049)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:2938)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:688)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:544)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:281)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:229)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:218)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:109)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:75)
        at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
        at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
        at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:134)
        at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:113)
        at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1602)
        at org.springframework.orm.hibernate3.HibernateTemplate$31.doInHibernate(HibernateTemplate.java:846)
        at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:366)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:844)
        at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:836)
        at com.dao.implement.EmauxDaoImpl.recupererEmauxAdresse(EmauxDaoImpl.java:67)
        at com.emaux.delegate.EmauxDaoDelegue.emauxAdresse(EmauxDaoDelegue.java:30)
        at com.emaux.delegate.EmauxDaoDelegue$$FastClassByCGLIB$$c767579d.invoke(<generated>)
        at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
        at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:594)
        at com.emaux.delegate.EmauxDaoDelegue$$EnhancerByCGLIB$$660d1f2d.emauxAdresse(<generated>)
        at com.emaux.delegate.EmauxDelegue.courseEnvoyerBatchEmaux(EmauxDelegue.java:46)
        at com.userManagement.action.UsagerGestionMoteur.createUser(UsagerGestionMoteur.java:90)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)
        at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)
        at org.apache.struts.actions.LookupDispatchAction.execute(LookupDispatchAction.java:150)
        at org.springframework.web.struts.DelegatingActionProxy.execute(DelegatingActionProxy.java:106)
        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
        at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
        at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)
Caused by:  graffiti.MAILBOX is not mapped.
        ... 64 more



Name and version of the database you are using:
MYSQL database version 5

The generated SQL (show_sql=true):

Code:
2009-03-08 16:44:05,807 DEBUG [org.hibernate.engine.query.QueryPlanCache] unable to locate HQL query plan in cache; generating (from MAILBOX where status= P)
2009-03-08 16:44:05,947 DEBUG [org.hibernate.hql.ast.QueryTranslatorImpl] parse() - HQL: from MAILBOX where status= P
2009-03-08 16:44:05,965 DEBUG [org.hibernate.hql.ast.AST] --- HQL AST ---
\-[QUERY] 'query'
    +-[SELECT_FROM] 'SELECT_FROM'
    |  \-[FROM] 'from'
    |     \-[RANGE] 'RANGE'
    |        \-[IDENT] 'MAILBOX'
    \-[WHERE] 'where'
       \-[EQ] '='
          +-[IDENT] 'status'
          \-[IDENT] 'P'

Debug level Hibernate log excerpt:


[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 08, 2009 8:34 am 
Newbie

Joined: Sat Mar 07, 2009 4:24 am
Posts: 10
You should use entity name in HQL queries instead of table name ("EmauxDaoBean" in your case).

_________________
-- please rate helpful posts --

Best regards,
Boris Okunskiy.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 09, 2009 2:57 am 
Newbie

Joined: Sun Mar 08, 2009 4:33 am
Posts: 2
Thanks. Ur post have solve my problems.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.