[CDO] best practice for 'getting' a resource [message #422972] |
Fri, 19 September 2008 13:30  |
Eclipse User |
|
|
|
I have a slightly unusual problem that I am having trouble solving.
I have a model that is persisted with CDO. When I create an empty
database I call transaction.createResource() to create the resource...
When I subsequently access an existing resource I call
transaction.getResource() to get the resource... No problems except that
I need to provide the user with the ability to drop the database, create
a new one and the create the resource from scratch. I have not been able
to consistently 'get' the resource when I don't know whether the
resource has previously been created or not. That is I want to be able
to return a resource whether I need to create or just get the resource.
What is the suggested best practice here, for 'providing' a CDO backed
resource.?
Thanks,
Mark.
|
|
|
|
|
Re: [CDO] best practice for 'getting' a resource [message #422985 is a reply to message #422976] |
Fri, 19 September 2008 16:16   |
Eclipse User |
|
|
|
Eike,
I am not using getOrCreateResource() but I have a problem that only the
first session seems to work. If I create a new resource, then add an
object and save and exit, then run again I seem to get a resource but
the call to resource.getContents() always fails. If I drop the database
I can then create and access the resource, but never again.
I have also tried with the EnhancedEditor and the CDO launcher. If I
ONLY use the editor everything works fine, even subsequent access.
Mark.
Mark Geib wrote:
> Beautiful Eike.
>
> I guess I need to start reading release notes and the javadoc.
>
> It just gets BETTER and BETTER..
>
> Thanks,
> Mark.
>
> Eike Stepper wrote:
>> Hi Mark,
>>
>> I think these two methods are the key:
>>
>> - org.eclipse.emf.cdo.CDOView.hasResource(String)
>> - org.eclipse.emf.cdo.CDOTransaction.getOrCreateResource(Strin g)
>>
>> They were added through:
>>
>> 217236: Provide a way to query if a specific resource (path) exists
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=217236
>>
>> Cheers
>> /Eike
>>
>>
>>
>> Mark Geib schrieb:
>>> I have a slightly unusual problem that I am having trouble solving.
>>>
>>> I have a model that is persisted with CDO. When I create an empty
>>> database I call transaction.createResource() to create the
>>> resource... When I subsequently access an existing resource I call
>>> transaction.getResource() to get the resource... No problems except
>>> that I need to provide the user with the ability to drop the
>>> database, create a new one and the create the resource from scratch.
>>> I have not been able to consistently 'get' the resource when I don't
>>> know whether the resource has previously been created or not. That is
>>> I want to be able to return a resource whether I need to create or
>>> just get the resource.
>>>
>>> What is the suggested best practice here, for 'providing' a CDO
>>> backed resource.?
>>>
>>> Thanks,
>>> Mark.
|
|
|
|
Re: [CDO] best practice for 'getting' a resource [message #422988 is a reply to message #422987] |
Fri, 19 September 2008 18:04   |
Eclipse User |
|
|
|
Simon,
I am sorry for the false alarm. I honestly don't know what I did, but
when I went to reproduce for you...it all works.
I guess I should go home..
Sorry again,
Mark.
Simon McDuff wrote:
> When you say it fails, what does that mean ?
> Did you have an exception, stack trace, getContents is empty ?
>
> Also which version of CDO are you using ?
>
> The best would be to provide a testcase! :-)
>
> Are you using Derby or Teneo as your database ?
>
> Simon
>
> Simon
>
> "Mark Geib" <mark.geib@echostar.com> a écrit dans le message de news:
> gb11af$4n2$1@build.eclipse.org...
>> Eike,
>>
>> I am not using getOrCreateResource() but I have a problem that only the
>> first session seems to work. If I create a new resource, then add an
>> object and save and exit, then run again I seem to get a resource but the
>> call to resource.getContents() always fails. If I drop the database I can
>> then create and access the resource, but never again.
>>
>> I have also tried with the EnhancedEditor and the CDO launcher. If I ONLY
>> use the editor everything works fine, even subsequent access.
>>
>> Mark.
>>
>> Mark Geib wrote:
>>> Beautiful Eike.
>>>
>>> I guess I need to start reading release notes and the javadoc.
>>>
>>> It just gets BETTER and BETTER..
>>>
>>> Thanks,
>>> Mark.
>>>
>>> Eike Stepper wrote:
>>>> Hi Mark,
>>>>
>>>> I think these two methods are the key:
>>>>
>>>> - org.eclipse.emf.cdo.CDOView.hasResource(String)
>>>> - org.eclipse.emf.cdo.CDOTransaction.getOrCreateResource(Strin g)
>>>>
>>>> They were added through:
>>>>
>>>> 217236: Provide a way to query if a specific resource (path) exists
>>>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=217236
>>>>
>>>> Cheers
>>>> /Eike
>>>>
>>>>
>>>>
>>>> Mark Geib schrieb:
>>>>> I have a slightly unusual problem that I am having trouble solving.
>>>>>
>>>>> I have a model that is persisted with CDO. When I create an empty
>>>>> database I call transaction.createResource() to create the resource...
>>>>> When I subsequently access an existing resource I call
>>>>> transaction.getResource() to get the resource... No problems except
>>>>> that I need to provide the user with the ability to drop the database,
>>>>> create a new one and the create the resource from scratch. I have not
>>>>> been able to consistently 'get' the resource when I don't know whether
>>>>> the resource has previously been created or not. That is I want to be
>>>>> able to return a resource whether I need to create or just get the
>>>>> resource.
>>>>>
>>>>> What is the suggested best practice here, for 'providing' a CDO backed
>>>>> resource.?
>>>>>
>>>>> Thanks,
>>>>> Mark.
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 1.10619 seconds