Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] queryXRefs and an EReference with EType 'EObject'
[CDO] queryXRefs and an EReference with EType 'EObject' [message #1112877] Fri, 20 September 2013 09:51 Go to next message
Per Sterner is currently offline Per SternerFriend
Messages: 91
Registered: October 2011
Member
Hello!

we have/had one EClass which has an EReference with an EType 'EObject'. If an item is set here it is not found with CDOView.queryXRefs. I changed my model and defined an Interface and used this as the EType and it works.

The example fails, if the EType is 'EObject'

  public void testMyXref() throws Exception
  {
    PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();

    Supplier supplier = getModel1Factory().createSupplier();
    supplier.setObject(purchaseOrder1);

    CDOSession session1 = openSession();
    CDOTransaction transaction1 = session1.openTransaction();

    CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
    resource.getContents().add(supplier);
    resource.getContents().add(purchaseOrder1);

    transaction1.commit();

    /******************/

    List<CDOObjectReference> rc = transaction1.queryXRefs(CDOUtil.getCDOObject(purchaseOrder1), new EReference[] {});
    System.out.println(rc);
    assertEquals(1, rc.size());

  }


The 'Referential Integrity Check' is affected too on deleting the referenced item. The result is a stale object without a commit exception.

Perhaps a EType with EObject should not be allowed for performance reasons? At least there should be an exception/warning when using such an EClass Smile

Regards,

Per Sterner
Re: [CDO] queryXRefs and an EReference with EType 'EObject' [message #1112890 is a reply to message #1112877] Fri, 20 September 2013 10:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6680
Registered: July 2009
Senior Member
Am 20.09.2013 11:51, schrieb Per Sterner:
> Hello!
>
> we have/had one EClass which has an EReference with an EType 'EObject'. If an item is set here it is not found with
> CDOView.queryXRefs. I changed my model and defined an Interface and used this as the EType and it works.
>
> The example fails, if the EType is 'EObject'
I'm not exactly sure what you mean but we've recently fixed some bugs in the handling of inheritance and EObject:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=416285
https://bugs.eclipse.org/bugs/show_bug.cgi?id=416366

Maybe your problem is already fixed. Can you try that out in master/4.3?

Are you suggesting that the test case below fails as it is?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
>
> public void testMyXref() throws Exception
> {
> PurchaseOrder purchaseOrder1 = getModel1Factory().createPurchaseOrder();
>
> Supplier supplier = getModel1Factory().createSupplier();
> supplier.setObject(purchaseOrder1);
>
> CDOSession session1 = openSession();
> CDOTransaction transaction1 = session1.openTransaction();
>
> CDOResource resource = transaction1.createResource(getResourcePath("/test1"));
> resource.getContents().add(supplier);
> resource.getContents().add(purchaseOrder1);
>
> transaction1.commit();
>
> /******************/
>
> List<CDOObjectReference> rc = transaction1.queryXRefs(CDOUtil.getCDOObject(purchaseOrder1), new EReference[] {});
> System.out.println(rc);
> assertEquals(1, rc.size());
>
> }
>
>
> The 'Referential Integrity Check' is affected too on deleting the referenced item. The result is a stale object
> without a commit exception.
>
> Perhaps a EType with EObject should not be allowed for performance reasons? At least there should be an
> exception/warning when using such an EClass :)
>
> Regards,
>
> Per Sterner
>


Re: [CDO] queryXRefs and an EReference with EType 'EObject' [message #1113069 is a reply to message #1112890] Fri, 20 September 2013 15:43 Go to previous messageGo to next message
Per Sterner is currently offline Per SternerFriend
Messages: 91
Registered: October 2011
Member
I updated to the current cdo-master branch in my testworkspace. And made another test-function which uses the Model6 Smile

The test fails.

The function EcoreUtil.UsageCrossReferencer.find returns one match as expected.

The code-snippet works directly in the class XRefTest.

public void testPer1() throws Exception
  {
    A itemA = getModel6Factory().createA();
    CanReferenceLegacy itemRefContainer = getModel6Factory().createCanReferenceLegacy();

    itemRefContainer.setSingleReference(itemA);

    CDOSession session1 = openSession();
    CDOTransaction transaction = session1.openTransaction();

    CDOResource resource = transaction.createResource(getResourcePath("/test1"));
    resource.getContents().add(itemA);
    resource.getContents().add(itemRefContainer);

    transaction.commit();

    List<CDOObjectReference> rc = transaction.queryXRefs(CDOUtil.getCDOObject(itemA), new EReference[] {});
//    Collection<Setting> rc2 = EcoreUtil.UsageCrossReferencer.find(itemA, (Resource)resource);
//    System.out.println(rc.size() + " ; " + rc2.size());
//    System.out.println(itemRefContainer.getSingleReference() + " <==> " + itemA);
    assertEquals(1, rc.size());
  }
Re: [CDO] queryXRefs and an EReference with EType 'EObject' [message #1113104 is a reply to message #1113069] Fri, 20 September 2013 16:48 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6680
Registered: July 2009
Senior Member
Am 20.09.2013 17:43, schrieb Per Sterner:
> I updated to the current cdo-master branch in my testworkspace. And made another test-function which uses the Model6 :)
>
> The test fails.
Ok, thanks for trying it out with master. Please submit a bugzilla and attach your test case there. I'll try to look at
it ASAP ;-)

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


>
> The function EcoreUtil.UsageCrossReferencer.find returns one match as expected.
>
> The code-snippet works directly in the class XRefTest.
>
>
> public void testPer1() throws Exception
> {
> A itemA = getModel6Factory().createA();
> CanReferenceLegacy itemRefContainer = getModel6Factory().createCanReferenceLegacy();
>
> itemRefContainer.setSingleReference(itemA);
>
> CDOSession session1 = openSession();
> CDOTransaction transaction = session1.openTransaction();
>
> CDOResource resource = transaction.createResource(getResourcePath("/test1"));
> resource.getContents().add(itemA);
> resource.getContents().add(itemRefContainer);
>
> transaction.commit();
>
> List<CDOObjectReference> rc = transaction.queryXRefs(CDOUtil.getCDOObject(itemA), new EReference[] {});
> // Collection<Setting> rc2 = EcoreUtil.UsageCrossReferencer.find(itemA, (Resource)resource);
> // System.out.println(rc.size() + " ; " + rc2.size());
> // System.out.println(itemRefContainer.getSingleReference() + " <==> " + itemA);
> assertEquals(1, rc.size());
> }
>


Re: [CDO] queryXRefs and an EReference with EType 'EObject' [message #1114771 is a reply to message #1113104] Mon, 23 September 2013 07:17 Go to previous message
Per Sterner is currently offline Per SternerFriend
Messages: 91
Registered: October 2011
Member
Bugzilla entry:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=417782
Previous Topic:[CDO] asynchronous auditing to improve performance
Next Topic:Structure of p2 download site(s) for EMF
Goto Forum:
  


Current Time: Wed Oct 04 14:28:26 GMT 2023

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

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

Back to the top