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>