|
Re: [Teneo] Multiple distinct resources [message #799093 is a reply to message #799039] |
Wed, 15 February 2012 12:40 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hmm, by first loading the children in a separate resource and then load the father in their resource, using the same
hibernate session:
http://wiki.eclipse.org/Teneo/Hibernate/EMF_Resource#Sharing_one_Session_between_Resources.2C_One_transaction_when_saving_multiple_resources
btw, if you are not building a rcp, then I would not use resources but go to the database directly using HQL and other
direct Hibernate apis, is much simpler.
gr. Martin
On 02/15/2012 12:14 PM, Matthias R. wrote:
> I separated my EMF model in two distinct HinbernateResources (different tables in one database). Saving works fine but
> how can I load these resources with the same distinction afterwards?
> Let's assume there are two nodes: Father and Child. Fathers refer to children with a non-containment reference. Fathers
> shall be loaded to one resource, children to the other. If I load the father resource with "query1=FROM Father", the
> referenced table "Child" will be loaded in the same resource (or in no resource if I specify
> StoreResource.NOT_SET_ERESOURCE), although I already loaded all children in the Child resource beforehand. How can I
> achieve that Fathers in the Father resource will reference Childs in the Child resource?
>
> Thanks, matthias
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
|
Re: [Teneo] Multiple distinct resources [message #799341 is a reply to message #799127] |
Wed, 15 February 2012 19:19 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Matthias,
Hmm what you can do is open all resources using one hibernate session (see the link in my previous reply). But the
problem is that the hibernate session caches all read objects, so over time your app may use too much memory.
But what you can do is to subclass the hibernate resource and when unloading, remove the father object from the session
(look at session.evict()). That should work afaics.
gr. Martin
On 02/15/2012 02:31 PM, Matthias R. wrote:
> Thanks Martin.
> Maybe some more background information is useful to understand my problem. I am building an RAP application where I
> differentiate between two kinds of EObjects. "Children" shall be immutable, loaded once during startup in order to
> prevent lots of database accesses later. "Fathers" will be created, updated and removed rather often. Every father
> refers to a child by a non-containment reference. If a father is not needed anymore, I want to unload it.
> My approach to achieve this is to have two different HibernateResources: one for Children and one for Fathers. The Child
> resource is loaded completely during startup. The Father resource is loaded when it is needed and unloaded when it is
> not needed anymore. Do you think that is a reasonable approach for my goals?
> But when I load the Father resource with "query1=FROM Father") and access the children EReference, all children will be
> loaded again (and attached to the father resource) although the child resource including all children has already been
> loaded during startup.
> BR, matthias
--
With Regards, Martin Taal
Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
|
|
|
Powered by
FUDForum. Page generated in 0.03112 seconds