From the stack trace below, you will see I get the following error:
net.sf.hibernate.QueryException: in expected: d [select from AssetDetail d where d.irn = :irn]
I have tried many variatons (e.g. removing select, not providing an alias), all with the same message.
I am doing similar things with other persistent objects, with no problem.
I can't see what is different here. Perhaps, I am missing something obvious.
Any ideas?
Thanks
Rob
Hibernate version: 2.1.6
Mapping documents:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<class
name="com.trustetc.model.AssetDetail"
table="TRALOGSL1" >
<meta attribute="class-description" inherit="false">
@hibernate.class
table="TRALOGSL1"
</meta>
<id type="java.lang.Integer" column="id" unsaved-value="null" >
<meta attribute="field-description" inherit="false">
@hibernate.id
generator-class="native"
</meta>
<generator class="native"/>
</id>
<property
name="irn"
column="CUSIP#"
type="java.lang.String"
length="9" >
<meta attribute="field-description">
@hibernate.property
column="CUSIP#"
</meta>
</property>
<property
name="detailLine"
column="INAMES"
type="java.lang.String"
length="35"
>
<meta attribute="field-description">
@hibernate.property
column="INAMES"
</meta>
</property>
</class>
<hibernate-mapping>
Code between sessionFactory.openSession() and session.close():Code:
public List getAssetDetailsByIrn(String irn) throws Exception {
Vector details = new Vector();
Session s = getSession();
try {
Query query = s.createQuery(getAssetDetailsByIrnQueryString);
details.addAll(
query.setParameter("irn", irn, Hibernate.STRING).list());
} catch (Exception e) {
logger.warn("Could not get asset description lines for IRN " + irn);
e.printStackTrace();
throw new Exception (e);
} finally {
s.close();
}
return details;
}
Full stack trace of any exception that occurs:
Quote:
net.sf.hibernate.QueryException: in expected: d [select from AssetDetail d where d.irn = :irn]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:294)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1562)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533)
at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
at com.trustetc.dao.hibernate.AssetDetailDaoHibernate.getAssetDetailsByIrn(AssetDetailDaoHibernate.java:68)
Name and version of the database you are using: db2 on AS/400