I'm running out of ideas, but it seems as if there are spaces being added to 
EmployeeClass
and to familyName. These would definitly break the query.

Maybe possibly it's velocity to blame, I only tested the tutorial in groovy so 
why not try:

{{groovy}}
xc = xcontext.getContext();
for(String name : xc.getWiki().getHibernateStore().search("SELECT e.familyName 
from EmployeeClass as e", 0,0, xc));
    println(name);
}
{{/groovy}}

I also have it going directally to XWikiHibernateStore to run the query.

Caleb James DeLisle

farouk korteby wrote:
> I tried with "select e.familyName from XWiki.EmployeeClass as e" but i get
> the some exception :
> 
> Caused by: com.xpn.xwiki.XWikiException: Error number 3223 in 3:
> Exception while searching documents with sql SELECT e.familyName from
> XWiki.EmployeeClass e
> Wrapped Exception: XWiki.EmployeeClass is not mapped family Name from
> XWiki.Employee Class e?
> <http://127.0.0.1:8080/xwiki/bin/edit/SELECT+e.familyName+from+XWiki/EmployeeClass+e?parent=XWiki.QueryEmployee>
>       at 
> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2142)
>       at 
> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2072)
>       at 
> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2061)
>       at com.xpn.xwiki.store.XWikiCacheStore.search(XWikiCacheStore.java:581)
>       at com.xpn.xwiki.XWiki.search(XWiki.java:1569)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>       at java.lang.reflect.Method.invoke(Unknown Source)
>       at 
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
>       at 
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
>       at 
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
>       … 97 more
> 
> is there a way to get the list of mapped classes in XWiki or Hibernate APIs
> ?
> 
> 
> 2009/12/5 Caleb James DeLisle <[email protected]>
> 
>> You are so close, it is successfully putting data into the custom mapped
>> table and
>> presumably taking it out. The entire problem has to be in the query.
>> Can you confirm that the EmployeeClass document is in the space XWiki?
>> You might try "select e.familyName from XWiki.EmployeeClass as e"
>>
>> Caleb James DeLisle
>>
>> farouk korteby wrote:
>>> *
>>> i find all configuration correct, u can verify also. (i use XE 2.0.3)
>>>
>>> can i get a API to list all mapped tables in hibernate ?
>>>
>>> 1- My xwiki.cfg*
>>> #-# Allow or disable custom mapping for particular XClasses. Custom
>> mapping
>>> may increase the performance of certain
>>> #-# queries when large number of objects from particular classes are used
>> in
>>> the wiki.
>>> *xwiki.store.hibernate.custommapping=1*
>>> #-# Dynamic custom mapping.
>>> *xwiki.store.hibernate.custommapping.dynamic=1*
>>> *
>>> *
>>> *2- My data in custom mapping table*
>>> see the image attached bellow
>>>
>>> *3- Simple Query without custom mapping*
>>> *
>>> *
>>> *code *:
>>> *#set($sql = "select doc.fullName from XWikiDocument as doc, BaseObject
>> as
>>> obj where obj.name=doc.fullName and obj.className='XWiki.EmployeeClass'
>> ")*
>>> *
>>> *
>>> *#foreach($EmployeeDoc in $xwiki.search($sql))*
>>> ** $familyName*
>>> *#end*
>>> *
>>> *
>>> *Result :*
>>>
>>>
>>>    - XWiki.EmployeeTemplate
>>>    - Main.Employee1
>>>    - Main.Employee2
>>>
>>>
>>> *4- Query with custom mapping*
>>> *
>>> *
>>> *
>>> code :
>>> #set($xc = $context.getContext())
>>> #set($sql = "SELECT e.familyName from EmployeeClass e")
>>> #set($familyNames = $xc.getWiki().search($sql , $xc))
>>> #foreach($familyName in $familyNames)
>>> * $familyName
>>> #end
>>>
>>> Result :
>>>
>>> Caused by: com.xpn.xwiki.XWikiException: Error number 3223 in 3:
>>> Exception while searching documents with sql SELECT e.familyName from
>>> EmployeeClass e
>>> Wrapped Exception: EmployeeClass is not mapped family Name from
>>> Employee Class e?
>>> <
>> http://127.0.0.1:8080/xwiki/bin/edit/SELECT+e/familyName+from+EmployeeClass+e?parent=XWiki.QueryEmployee
>>>       at
>> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2142)
>>>       at
>> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2072)
>>>       at
>> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2061)
>>>       at
>> com.xpn.xwiki.store.XWikiCacheStore.search(XWikiCacheStore.java:581)
>>>       at com.xpn.xwiki.XWiki.search(XWiki.java:1569)
>>>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>       at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>       at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>       at java.lang.reflect.Method.invoke(Unknown Source)
>>>       at
>> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
>>>       at
>> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
>>>       at
>> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
>>>       … 97 more
>>>
>>>
>>>
>>>
>>> *
>>> 2009/12/5 Caleb James DeLisle <[email protected]>
>>>
>>>> Try looking at an employee object, with the object editor
>>>> if there is something wrong with the mapping, it will likely throw an
>> error
>>>> rather than
>>>> give you the information you inputted.
>>>>
>>>> If you used exactly the same fields in the class as the tutorial
>>>> and you ran the groovy script
>>>> and clicked "To inject custom mapping for this class, click here" here.
>>>> (an I assume you did since you have xwikicustom_xwiki_employee table)
>>>> then your mapping should be fine.
>>>>
>>>> Are you sure you stopped the server and changed
>>>> # xwiki.store.hibernate.custommapping.dynamic=0
>>>> to =1
>>>> then restarted it.
>>>> (this mistake busted me a few times ;) )
>>>>
>>>> Caleb James DeLisle
>>>>
>>>> farouk korteby wrote:
>>>>> Yes, i get xwikicustom_xwiki_employee table
>>>>> and SELECT * FROM xwikicustom_xwiki_employee; query show me a liste of
>>>>> my employees.
>>>>>
>>>>> But i think the mastake is in the mapping.
>>>>>
>>>>> 2009/12/5 Caleb James DeLisle <[email protected]>
>>>>>
>>>>>> Can you get a list of tables in your database? There should be a table
>>>>>> called
>>>>>> xwikicustom_xwiki_employee
>>>>>>
>>>>>> Did you run the test command from the sql console?
>>>>>> SELECT * FROM xwikicustom_xwiki_employee;
>>>>>>
>>>>>>
>>>>>> Caleb James DeLisle
>>>>>>
>>>>>>
>>>>>> farouk korteby wrote:
>>>>>>> *Hi,*
>>>>>>> *
>>>>>>> *
>>>>>>> *I try to implement this tutorial : *
>>>>>>> http://dev.xwiki.org/xwiki/bin/view/Drafts/DynamicCustomMapping*
>>>>>>>
>>>>>>> *
>>>>>>> *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.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2072)
>>>>>>> at
>>>>>>>
>> com.xpn.xwiki.store.XWikiHibernateStore.search(XWikiHibernateStore.java:2061)
>>>>>>> at
>> com.xpn.xwiki.store.XWikiCacheStore.search(XWikiCacheStore.java:581)
>>>>>>> at com.xpn.xwiki.XWiki.search(XWiki.java:1569)
>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
>>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
>>>>>>> at java.lang.reflect.Method.invoke(Unknown Source)
>>>>>>> at
>>>>>>>
>> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:389)
>>>>>>> at
>>>>>>>
>> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:378)
>>>>>>> at
>>>>>>>
>> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:270)
>>>>>>> ... 100 more
>>>>>>>
>>>>>>> *Any ideas ?*
>>>>>>>
>>>>>>>
>>>>>> _______________________________________________
>>>>>> devs mailing list
>>>>>> [email protected]
>>>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>>>
>>>>>
>>>> _______________________________________________
>>>> devs mailing list
>>>> [email protected]
>>>> http://lists.xwiki.org/mailman/listinfo/devs
>>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> devs mailing list
>>> [email protected]
>>> http://lists.xwiki.org/mailman/listinfo/devs
>> _______________________________________________
>> devs mailing list
>> [email protected]
>> http://lists.xwiki.org/mailman/listinfo/devs
>>
> 
> 
> 

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to