Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » Resource.load is emptying all resources
Resource.load is emptying all resources [message #125708] |
Wed, 11 June 2008 08:43 |
Eclipse User |
|
|
|
Originally posted by: felixostertag.web.de
hi again,
right now i have discovered a new problem. i try using an
sessioncontroller in a Teneo/Hibernate environment. and everytime i reload
a resource from the DB it clears all my copys of the old resource too.
as the URI i use: "hbxml://?" + HibernateResource.SESSION_CONTROLLER_PARAM
+ "=ECUall"
e.g. i have a resource res1 containing one EObject, this one i save to the
DB. after changing it a bit i want to keep whats in res1, but also want to
load the previously saved contents into a new resource res2. when i now do
a res2.load(...) it not only fails to correctly load the stuff from the DB
to the res2, but also emptys the res1.
i thought it might be because both have the same URI, but even if i change
the res1 URI to something completely different that happens.
i have no idea why that is happening, but hopefully someone else does?
thx for your patience
felix
|
|
|
Re: Resource.load is emptying all resources [message #125778 is a reply to message #125708] |
Wed, 11 June 2008 20:49 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Felix,
I think the following happens. You use a session controller which probably means that the two
resources res1 and res2 share the same session. This means that the objects in both resources are
the same (the exact same in-memory instance). When you load the same objects again in res2 then EMF
will remove the objects from res1 automatically (an EObject can belong to only one resource).
I think this can be solved by not using a sessioncontroller but let each resource have its own
session (which is the default).
gr. Martin
Felix wrote:
> hi again,
> right now i have discovered a new problem. i try using an
> sessioncontroller in a Teneo/Hibernate environment. and everytime i
> reload a resource from the DB it clears all my copys of the old resource
> too.
> as the URI i use: "hbxml://?" +
> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>
> e.g. i have a resource res1 containing one EObject, this one i save to
> the DB. after changing it a bit i want to keep whats in res1, but also
> want to load the previously saved contents into a new resource res2.
> when i now do a res2.load(...) it not only fails to correctly load the
> stuff from the DB to the res2, but also emptys the res1.
> i thought it might be because both have the same URI, but even if i
> change the res1 URI to something completely different that happens.
>
> i have no idea why that is happening, but hopefully someone else does?
>
> thx for your patience
> felix
>
--
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: Resource.load is emptying all resources [message #125853 is a reply to message #125778] |
Thu, 12 June 2008 15:51 |
Eclipse User |
|
|
|
Originally posted by: felixostertag.web.de
thx for your answer, but when i don't use the session controller, i got
another error (my most favorite one ;) )
"Caused by: org.hibernate.HibernateException: Illegal attempt to associate
a collection with two open sessions"
in both cases, with or without the session controller, the first time i
save the model to the DB, i dont experience errors. it works great then.
but when i modify my model (or even don't modify) and save it again, i
either get the problem mentioned before, or the two-open-session-problem.
right now saving is done with following steps:
1. i convert the XML resource which the programm is working with to a
hibernate resource. (by simply creating a new resource and put all
contents from the old one to the new one)
2. i load my previously saved resource from the DB to check if my resource
is the most recent one, or someone else changed something
2.5 i tried deleting the model from the DB before saving again, but it has
no effect on the error...
3. i save my working resource to the DB (using
resource.save(Collections.EMPY_MAP), this is also where my two session
error occurs)
4. i convert the hibernate resource back to the XML resource (same like
before, just the other way around)
thx a lot for your help!
felix
Martin Taal wrote:
> Hi Felix,
> I think the following happens. You use a session controller which probably
means that the two
> resources res1 and res2 share the same session. This means that the objects
in both resources are
> the same (the exact same in-memory instance). When you load the same objects
again in res2 then EMF
> will remove the objects from res1 automatically (an EObject can belong to
only one resource).
> I think this can be solved by not using a sessioncontroller but let each
resource have its own
> session (which is the default).
> gr. Martin
> Felix wrote:
>> hi again,
>> right now i have discovered a new problem. i try using an
>> sessioncontroller in a Teneo/Hibernate environment. and everytime i
>> reload a resource from the DB it clears all my copys of the old resource
>> too.
>> as the URI i use: "hbxml://?" +
>> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>>
>> e.g. i have a resource res1 containing one EObject, this one i save to
>> the DB. after changing it a bit i want to keep whats in res1, but also
>> want to load the previously saved contents into a new resource res2.
>> when i now do a res2.load(...) it not only fails to correctly load the
>> stuff from the DB to the res2, but also emptys the res1.
>> i thought it might be because both have the same URI, but even if i
>> change the res1 URI to something completely different that happens.
>>
>> i have no idea why that is happening, but hopefully someone else does?
>>
>> thx for your patience
>> felix
>>
|
|
|
Re: Resource.load is emptying all resources [message #125866 is a reply to message #125853] |
Thu, 12 June 2008 17:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Felix,
Are there any references from the first hibernate resource (created in step 1) to the second
resource (created in step 2)?
What nl. happens is if you save a resource it actually saves everything in the resource and all
objects which are related to objects in the resource (depending on the cascade settings). So the
other objects can be in the other resource which has another session and then hibernate tries to
connect the collections in the other objects to the saving session.
Is this a possibility?
gr. Martin
Felix wrote:
> thx for your answer, but when i don't use the session controller, i got
> another error (my most favorite one ;) )
>
> "Caused by: org.hibernate.HibernateException: Illegal attempt to
> associate a collection with two open sessions"
>
> in both cases, with or without the session controller, the first time i
> save the model to the DB, i dont experience errors. it works great then.
> but when i modify my model (or even don't modify) and save it again, i
> either get the problem mentioned before, or the two-open-session-problem.
>
> right now saving is done with following steps:
> 1. i convert the XML resource which the programm is working with to a
> hibernate resource. (by simply creating a new resource and put all
> contents from the old one to the new one)
> 2. i load my previously saved resource from the DB to check if my
> resource is the most recent one, or someone else changed something
> 2.5 i tried deleting the model from the DB before saving again, but it
> has no effect on the error...
> 3. i save my working resource to the DB (using
> resource.save(Collections.EMPY_MAP), this is also where my two session
> error occurs)
> 4. i convert the hibernate resource back to the XML resource (same like
> before, just the other way around)
>
> thx a lot for your help!
> felix
>
> Martin Taal wrote:
>
>> Hi Felix,
>> I think the following happens. You use a session controller which
>> probably
> means that the two
>> resources res1 and res2 share the same session. This means that the
>> objects
> in both resources are
>> the same (the exact same in-memory instance). When you load the same
>> objects
> again in res2 then EMF
>> will remove the objects from res1 automatically (an EObject can belong to
> only one resource).
>
>> I think this can be solved by not using a sessioncontroller but let each
> resource have its own
>> session (which is the default).
>
>> gr. Martin
>
>> Felix wrote:
>>> hi again,
>>> right now i have discovered a new problem. i try using an
>>> sessioncontroller in a Teneo/Hibernate environment. and everytime i
>>> reload a resource from the DB it clears all my copys of the old
>>> resource too.
>>> as the URI i use: "hbxml://?" +
>>> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>>>
>>> e.g. i have a resource res1 containing one EObject, this one i save
>>> to the DB. after changing it a bit i want to keep whats in res1, but
>>> also want to load the previously saved contents into a new resource
>>> res2. when i now do a res2.load(...) it not only fails to correctly
>>> load the stuff from the DB to the res2, but also emptys the res1.
>>> i thought it might be because both have the same URI, but even if i
>>> change the res1 URI to something completely different that happens.
>>>
>>> i have no idea why that is happening, but hopefully someone else does?
>>>
>>> thx for your patience
>>> felix
>>>
>
>
>
>
--
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: Resource.load is emptying all resources [message #619239 is a reply to message #125708] |
Wed, 11 June 2008 20:49 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Felix,
I think the following happens. You use a session controller which probably means that the two
resources res1 and res2 share the same session. This means that the objects in both resources are
the same (the exact same in-memory instance). When you load the same objects again in res2 then EMF
will remove the objects from res1 automatically (an EObject can belong to only one resource).
I think this can be solved by not using a sessioncontroller but let each resource have its own
session (which is the default).
gr. Martin
Felix wrote:
> hi again,
> right now i have discovered a new problem. i try using an
> sessioncontroller in a Teneo/Hibernate environment. and everytime i
> reload a resource from the DB it clears all my copys of the old resource
> too.
> as the URI i use: "hbxml://?" +
> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>
> e.g. i have a resource res1 containing one EObject, this one i save to
> the DB. after changing it a bit i want to keep whats in res1, but also
> want to load the previously saved contents into a new resource res2.
> when i now do a res2.load(...) it not only fails to correctly load the
> stuff from the DB to the res2, but also emptys the res1.
> i thought it might be because both have the same URI, but even if i
> change the res1 URI to something completely different that happens.
>
> i have no idea why that is happening, but hopefully someone else does?
>
> thx for your patience
> felix
>
--
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: Resource.load is emptying all resources [message #619245 is a reply to message #125778] |
Thu, 12 June 2008 15:51 |
Felix Messages: 11 Registered: July 2009 |
Junior Member |
|
|
thx for your answer, but when i don't use the session controller, i got
another error (my most favorite one ;) )
"Caused by: org.hibernate.HibernateException: Illegal attempt to associate
a collection with two open sessions"
in both cases, with or without the session controller, the first time i
save the model to the DB, i dont experience errors. it works great then.
but when i modify my model (or even don't modify) and save it again, i
either get the problem mentioned before, or the two-open-session-problem.
right now saving is done with following steps:
1. i convert the XML resource which the programm is working with to a
hibernate resource. (by simply creating a new resource and put all
contents from the old one to the new one)
2. i load my previously saved resource from the DB to check if my resource
is the most recent one, or someone else changed something
2.5 i tried deleting the model from the DB before saving again, but it has
no effect on the error...
3. i save my working resource to the DB (using
resource.save(Collections.EMPY_MAP), this is also where my two session
error occurs)
4. i convert the hibernate resource back to the XML resource (same like
before, just the other way around)
thx a lot for your help!
felix
Martin Taal wrote:
> Hi Felix,
> I think the following happens. You use a session controller which probably
means that the two
> resources res1 and res2 share the same session. This means that the objects
in both resources are
> the same (the exact same in-memory instance). When you load the same objects
again in res2 then EMF
> will remove the objects from res1 automatically (an EObject can belong to
only one resource).
> I think this can be solved by not using a sessioncontroller but let each
resource have its own
> session (which is the default).
> gr. Martin
> Felix wrote:
>> hi again,
>> right now i have discovered a new problem. i try using an
>> sessioncontroller in a Teneo/Hibernate environment. and everytime i
>> reload a resource from the DB it clears all my copys of the old resource
>> too.
>> as the URI i use: "hbxml://?" +
>> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>>
>> e.g. i have a resource res1 containing one EObject, this one i save to
>> the DB. after changing it a bit i want to keep whats in res1, but also
>> want to load the previously saved contents into a new resource res2.
>> when i now do a res2.load(...) it not only fails to correctly load the
>> stuff from the DB to the res2, but also emptys the res1.
>> i thought it might be because both have the same URI, but even if i
>> change the res1 URI to something completely different that happens.
>>
>> i have no idea why that is happening, but hopefully someone else does?
>>
>> thx for your patience
>> felix
>>
|
|
|
Re: Resource.load is emptying all resources [message #619246 is a reply to message #125853] |
Thu, 12 June 2008 17:37 |
Martin Taal Messages: 5468 Registered: July 2009 |
Senior Member |
|
|
Hi Felix,
Are there any references from the first hibernate resource (created in step 1) to the second
resource (created in step 2)?
What nl. happens is if you save a resource it actually saves everything in the resource and all
objects which are related to objects in the resource (depending on the cascade settings). So the
other objects can be in the other resource which has another session and then hibernate tries to
connect the collections in the other objects to the saving session.
Is this a possibility?
gr. Martin
Felix wrote:
> thx for your answer, but when i don't use the session controller, i got
> another error (my most favorite one ;) )
>
> "Caused by: org.hibernate.HibernateException: Illegal attempt to
> associate a collection with two open sessions"
>
> in both cases, with or without the session controller, the first time i
> save the model to the DB, i dont experience errors. it works great then.
> but when i modify my model (or even don't modify) and save it again, i
> either get the problem mentioned before, or the two-open-session-problem.
>
> right now saving is done with following steps:
> 1. i convert the XML resource which the programm is working with to a
> hibernate resource. (by simply creating a new resource and put all
> contents from the old one to the new one)
> 2. i load my previously saved resource from the DB to check if my
> resource is the most recent one, or someone else changed something
> 2.5 i tried deleting the model from the DB before saving again, but it
> has no effect on the error...
> 3. i save my working resource to the DB (using
> resource.save(Collections.EMPY_MAP), this is also where my two session
> error occurs)
> 4. i convert the hibernate resource back to the XML resource (same like
> before, just the other way around)
>
> thx a lot for your help!
> felix
>
> Martin Taal wrote:
>
>> Hi Felix,
>> I think the following happens. You use a session controller which
>> probably
> means that the two
>> resources res1 and res2 share the same session. This means that the
>> objects
> in both resources are
>> the same (the exact same in-memory instance). When you load the same
>> objects
> again in res2 then EMF
>> will remove the objects from res1 automatically (an EObject can belong to
> only one resource).
>
>> I think this can be solved by not using a sessioncontroller but let each
> resource have its own
>> session (which is the default).
>
>> gr. Martin
>
>> Felix wrote:
>>> hi again,
>>> right now i have discovered a new problem. i try using an
>>> sessioncontroller in a Teneo/Hibernate environment. and everytime i
>>> reload a resource from the DB it clears all my copys of the old
>>> resource too.
>>> as the URI i use: "hbxml://?" +
>>> HibernateResource.SESSION_CONTROLLER_PARAM + "=ECUall"
>>>
>>> e.g. i have a resource res1 containing one EObject, this one i save
>>> to the DB. after changing it a bit i want to keep whats in res1, but
>>> also want to load the previously saved contents into a new resource
>>> res2. when i now do a res2.load(...) it not only fails to correctly
>>> load the stuff from the DB to the res2, but also emptys the res1.
>>> i thought it might be because both have the same URI, but even if i
>>> change the res1 URI to something completely different that happens.
>>>
>>> i have no idea why that is happening, but hopefully someone else does?
>>>
>>> thx for your patience
>>> felix
>>>
>
>
>
>
--
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
|
|
|
Goto Forum:
Current Time: Mon Dec 23 19:29:59 GMT 2024
Powered by FUDForum. Page generated in 0.03169 seconds
|