If you don't mind declaring a dependency on
xwiki-core, you can
import org.xwiki.context.Execution
import com.xpn.xwiki.XWikiContext
import com.xpn.xwiki.XWiki
import com.xpn.xwiki.store.XWikiHibernateStore
and then use:
@Requirement
Execution ex;
XWikiHibernateStore hib =
ex.getContext().get("xwikicontext").getWiki().getHibernateStore();
and you have XWikiHibernateStore, from that you can get the SessionFactory, open a
session and do whatever.
The API:
Again I have a question. QueryManager class
allows to make queries to
the database, but, for example,
If I want to store an object in the database, I'll have to use
something similar to hibernate session's save() method.
What should I do?
2010/7/9 Igor Popov <gaurnar(a)gmail.com>om>:
Thanks, Alex! Never thought that it could be in
the "scripting"
section of docs...
2010/7/9 Alex Busenius <alex.busenius(a)xwiki.com>om>:
> I guess this will answer your question:
>
http://platform.xwiki.org/xwiki/bin/view/DevGuide/QueryGuide#HFromJavacompo…
>
> On 07/09/2010 06:28 AM, Igor Popov wrote:
>> Hi!
>>
>> I'm new to XWiki (especially to new "Component" design). My
question
>> is: can my component/plugin access the database
>> the same way XWiki does? I.e. if I write Hibernate mappings for my own
>> objects and reference them in XWiki hibernate.cfg.xml,
>> how can my plugin/component gain access to Hibernate session object?
>>
>> Previously I've written a plugin for XWiki and had to connect to
>> database separately from XWiki.
>> It was not convenient at all and I want to avoid this practice in
>> further development.
>> Moreover, I had some problems with using connection pool, so I think
>> it would be wiser to
>> use XWiki database connection.
>> _______________________________________________
>> users mailing list
>> users(a)xwiki.org
>>
http://lists.xwiki.org/mailman/listinfo/users
>>
> _______________________________________________
> users mailing list
> users(a)xwiki.org
>
http://lists.xwiki.org/mailman/listinfo/users
>
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org