That tutorial is for creating a hibernate mapping for the Employee entity.
There are numerous little mistakes which will make it fail rather silently,
resulting in the "you haven't mapped employee" error.
Caleb James DeLisle
Lukasz Skowronski wrote:
> ----- Original Message -----
> From: "farouk korteby"
>
>> *
>> *But when i try to execute this query *
>>
>> {{groovy}}
>> xc = xcontext.getContext();
>> for(String name : xc.getWiki().search("SELECT e.familyName from Employee
>> e",xc
>> ));
>> println(name);
>> }
>> {{/groovy}}
>>
>>
>> *i get this exception :*
>> Caused by: com.xpn.xwiki.XWikiException: Error number 3223 in 3: Exception
>> while searching documents with sql SELECT familyName from Employee
>> Wrapped Exception: Employee is not mapped [SELECT familyName from
>> Employee]
>> at
>> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2142)
>> (...)
>> at com.xpn.xwiki.XWiki.search(XWiki.java:1569)
>
> Yeah, that's a trap for novices, it was a little gotcha for me few days ago
> ;) The search parameter is called sql but in fact when you're using
> Hibernate store you're supposed to supply hql query, not the sql. And this
> is quite misleading since in Hibernate we can execute both hql and sql
> queries.
>
> I think you'd have to create Hibernate mapping for Employee entity to use
> XWiki.search method. I'm not sure how to pass sql query to the Hibernate
> store.
>
> Kind regards
> Lukasz
>
> _______________________________________________
> devs mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/devs
>
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs