Thanks, Caleb! That saved me a lot of time.
I have another question. Maybe I'm not getting the hibernate sessions
idea right, but
how can I get the current hibernate session that XWiki uses? I'm not
eager to open my own session, as
I'll have to make sure that it's closed correctly in the end.
I've tried XWikiHibernateStore.getSession() but it appears to give me
a null value.
2010/7/14 Caleb James DeLisle <calebdelisle(a)lavabit.com>om>:
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:
http://maven.xwiki.org/site/xwiki-core-parent/xwiki-core/apidocs/com/xpn/xw…
Caleb
Igor Popov wrote:
> 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
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org