-->
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: Problems with SQL-Query
PostPosted: Tue Sep 13, 2005 2:49 am 
Newbie

Joined: Thu Sep 08, 2005 2:45 am
Posts: 2
Hi!
I'm developing the FAQ component in an e-learning application using Hibernate 3.
In the mapping XML-file I've a class tag - mapping the Java object FaqSubject to the table faq_subject. Later in the same file I've created a sql-query returning FaqSubject. The problem is that I get a SQLException and it complains about a ".".
Do you have an idea what the problem is? I've tried all the solutions that I could think of but they all ended up in some exception.
I attach both the exception and the mapping file.
Thanks for your help.
Nazila

Quote:

Hibernate: select fas.* as fs.faq_subject_id as faq1_0_, fs.name as name21_0_, fs.lang as lang21_0_, fs.created as created21_0_, fs.modified as modified21_0_, fs.is_system as is6_21_0_, fs.created_by as created7_21_0_, fs.modified_by as modified8_21_0_
from faq_subject fas
left outer join faq_giver fg on (fg.giver = ? and fas.faq_subject_id = fg.faq_subject_id)
where fas.lang = ?
order by fg.seq
[PING PONG] WARN [TP-Processor3] org.hibernate.util.JDBCExceptionReporter JDBCExceptionReporter.logExceptions(71) | SQL Error: 0, SQLState: 42601
[PING PONG] ERROR [TP-Processor3] org.hibernate.util.JDBCExceptionReporter JDBCExceptionReporter.logExceptions(72) | ERROR: syntax error at or near "."

org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:59)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1596)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:112)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1414)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:153)
at net.pingpong.core.faq.dao.hibernate.FaqDAOHibernate.getGiverFaq(FaqDAOHibernate.java:98)



Code:

    <class name="FaqSubject" table="faq_subject">
       <cache usage="read-write"/>
        <id name="id" column="faq_subject_id" type="integer">
            <generator class="native"/>
        </id>

        <property name="subject" column="name" type="string" />

        <property name="language" column="lang" type="string" />
        <property name="created" column="created" type="timestamp" />
        <property name="modified" column="modified" type="timestamp" />
        <property name="system" column="is_system" type="boolean" />

        <many-to-one name="createdBy" column="created_by" class="net.pingpong.core.model.Person" />
        <many-to-one name="modifiedBy" column="modified_by" class="net.pingpong.core.model.Person" />

      <list name="faqs" table="faq_subject_coupling" outer-join="true" lazy="true">
         <cache usage="read-write" />
         <key column="faq_subject_id" />
         <index column="seq" type="integer" />
         <many-to-many class="Faq" column="faq_id"/>
      </list>
    </class>


   <sql-query name="GiverFaqQuery">
      <return alias="fs" class="FaqSubject"/>
      select fas.* as {fs.*}
      from faq_subject fas
      left outer join faq_giver fg on (fg.giver = :giver and fas.faq_subject_id = fg.faq_subject_id)
       where fas.lang = :language
       order by fg.seq
   </sql-query>



Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 3:39 am 
Newbie

Joined: Fri Sep 19, 2003 6:08 am
Posts: 1
It seem like the query that you had writen was incorrect.
Since this is a sql query, had you try it out on provided RDBMS sql client?
Is it working? Better give it a try.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 4:08 am 
Newbie

Joined: Thu Sep 08, 2005 2:45 am
Posts: 2
Hi!
I've already tried the query in a sql client and it worked fine.
I've modified the select to

Code:
      select {fs.*}
      from faq_subject fs
      left outer join faq_giver fg on (fg.giver = 'umu' and fs.faq_subject_id = fg.faq_subject_id)
       where fs.lang = 'sv'
       order by fg.seq


and recieve a new exception:
Quote:
Hibernate: select fs.faq_subject_id as faq1_0_, fs.name as name21_0_, fs.lang as lang21_0_, fs.created as created21_0_, fs.modified as modified21_0_, fs.is_system as is6_21_0_, fs.created_by as created7_21_0_, fs.modified_by as modified8_21_0_
from faq_subject fs
left outer join faq_giver fg on (fg.giver = 'umu' and fs.faq_subject_id = fg.faq_subject_id)
where fs.lang = 'sv'
order by fg.seq
[PING PONG] ERROR [TP-Processor3] org.hibernate.hql.PARSER ErrorCounter.reportError(35) | *** ERROR: line 1:64: unexpected token: where
net.pingpong.core.faq.action.SupportFaqAction : 436ms
[PING PONG] ERROR [TP-Processor3] org.apache.struts.taglib.tiles.InsertTag InsertTag$InsertHandler.doEndTag(920) | ServletException in '/pp/core/jsp/supportFAQ.jsp': Null attribute name
org.apache.jasper.JasperException: Null attribute name
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)


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.