i want to try to find out all the fieldValue based on fieldName
MNC.java:
`private Map <String, String>formFields = new HashMap<String, String>();
public void setFieldValue(String fieldName, String fieldValue) {
if (formFields == null) {
formFields = new HashMap<String, String>();
}
formFields.put(fieldName, fieldValue);
public Map<String, String> getFormFields() {
return formFields;
}
public void setFormFields(Map<String, String> formFields) {
this.formFields = formFields;
public String getFormField(String fieldName) {
if ((formFields != null) && (formFields.get(fieldName) != null)) {
return (String) formFields.get(fieldName);
}
return null;
}
MNC.hbm.xml:
<map name="formFields" table="mncformfields" cascade="all-delete-orphan" lazy="true">
<key column="id"/>
<index column="fieldName" type="string"/>
<element column="fieldValue" type="string"/>
</map>
`
here my query:
`query.append("SELECT users.name,sum(mncfield.fieldValue) as TotalMoney");
query.append("from MNC as mnc ");
query.append("left join mnc.formFields as mncfield ");
query.append("with (mnc.mncID= mncfield.id) and (mnc field.fieldName = 'mapMoney') ");
query.append("left join mnc.serviceExec as users ");
query.append("where (mnc.mncID= mncfield.id) ");
query.append("and mnc.serviceExec.id=users.id ");
query.append("and (mnc.mncDate between :startDate and :endDate) ");
query.append("and (mnc.mncGroup.id in (:ugIDs)) ");
query.append("group by users.name");
`
i found execption: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: with
if i comment this line://query.append("with (mnc.mnc ID= mncfield.id) and (mnc field.fieldName = 'mapMoney') ");
then i found java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: with-clause referenced two different from-clause elements
if i use on
instead of with
i found: org.hibernate.hql.ast.QuerySyntaxException: unexpected token: on