Hello.
I'm new to Hibernate.
I'm having problem on performing a query using a composite-id key. My schema was generated by Middle-Gen.
I'm using the following query:
Code:
String id="10";
List params = s.find("from Parameter as parameter where parameter.comp_id.id = ?",id,Hibernate.STRING);
Following is the hbm map file:
Code:
<class
name="com.test.Parameter"
table="PARAMETERS"
>
<composite-id name="comp_id" class="com.test.ParameterPK">
<key-property
name="id"
column="ID"
type="java.lang.String"
length="30"
/>
<key-property
name="value"
column="VALUE"
type="java.lang.String"
length="40"
/>
</composite-id>
<property
name="description"
type="java.lang.String"
column="DESCRIPTION"
length="50"
/>
</class>
When executing, it throws the following exception:
Code:
net.sf.hibernate.QueryException: unexpected token: as [from Parameter as parameter where parameter.comp_id.id = ?]
at net.sf.hibernate.hql.FromParser.token(FromParser.java:94)
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:293)
at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1493)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454)
at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1450)
Does anybody knows what I'm doing wrong?
Regards,
Flavio Matiello