Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] best practice for 'getting' a resource
[CDO] best practice for 'getting' a resource [message #422972] Fri, 19 September 2008 17:30 Go to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
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 #422974 is a reply to message #422972] Fri, 19 September 2008 17:57 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6478
Registered: July 2009
Senior Member
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 #422976 is a reply to message #422974] Fri, 19 September 2008 18:20 Go to previous messageGo to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
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 #422985 is a reply to message #422976] Fri, 19 September 2008 20:16 Go to previous messageGo to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
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 #422987 is a reply to message #422985] Fri, 19 September 2008 20:44 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
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
Re: [CDO] best practice for 'getting' a resource [message #422988 is a reply to message #422987] Fri, 19 September 2008 22:04 Go to previous messageGo to next message
Mark Geib is currently offline Mark GeibFriend
Messages: 432
Registered: July 2009
Senior Member
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.
>
>
Re: [CDO] best practice for 'getting' a resource [message #422989 is a reply to message #422988] Fri, 19 September 2008 22:10 Go to previous message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
I like false alarm!! :-)
Have a good evening!

"Mark Geib" <mark.geib@echostar.com> a
Previous Topic:Mapping xmi:type to EMF type
Next Topic:Re: Generating ecore model code with maven or ant
Goto Forum:
  


Current Time: Thu Feb 20 13:27:51 GMT 2020

Powered by FUDForum. Page generated in 0.02278 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top