Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] query on a view other than latest
[CDO] query on a view other than latest [message #1708399] Wed, 16 September 2015 09:22 Go to next message
Stefan Scheiber is currently offline Stefan ScheiberFriend
Messages: 18
Registered: February 2015
Junior Member
Hi,

I need to execute a CDO Query (CDO OCL) on a view with a timestamp (not latest).
However, I get ObjectNotFoundExceptions for Objects that are present in latest but missing in my view. My question is, if this is a bug or am I doing something wrong?

Below is my code:
  CDONet4jSession session = ...
  CDOCommitHistory history = session.getCommitInfoManager().getHistory();
  CDOCommitInfo commitInfo = history.getElement(1); // getting the previous commit
  CDOView view = session.openView(commit.getBranch(), commit.getTimeStamp());
  CDOQuery query = view.createQuery("ocl", "Book.allInstances()", null);
  List<Book> books = query.getResult(Book.class);


after the first commit i have the books with OID 4 and OID 5 (the result I'm expecting)
after the second commit i have the books with OID 9 and OID 10 (the books 4 and 5 were removed)
I get the error that Object with OID 9 cannot be found in view. That is correct, however, the query should not fail but deliver the correct answer OID4 and OID5.

The same code works if I make the query on the latest snapshot, i.e. if I fetch the latest commit
  CDOCommitInfo commitInfo = history.getFirstElement(); // getting the latest commit

Of course, in this case the result is OID9 and OID10.

Thanks,
Stefan
Re: [CDO] query on a view other than latest [message #1710707 is a reply to message #1708399] Thu, 08 October 2015 14:45 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stefan,

I've added the following test case to OCLQueryTest:

@Requires(IRepositoryConfig.CAPABILITY_AUDITING)
public void testAuditWithDetachedObject() throws Exception
{
assertEquals(NUM_OF_PRODUCTS, products.size());

Product1 p1 = getModel1Factory().createProduct1();
p1.setName("p1");
resource.getContents().add(0, p1);
CDOCommitInfo commitInfo = transaction.commit();

resource.getContents().remove(0);
transaction.commit();

CDOView audit = transaction.getSession().openView(commitInfo);
CDOQuery query = audit.createQuery("ocl", "Product1.allInstances()", getModel1Package().getProduct1());
query.setParameter("cdoLazyExtents", useLazyExtents());

List<Product1> result = query.getResult();
assertEquals(NUM_OF_PRODUCTS + 1, result.size());
}

And it passes successfully.

In your code, is it just an email typo that you use "commit" instead of the "commitInfo" you've obtained from the
history, or are you accidentally referring to a wrong time stamp?

Cheers
/Eike

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



Am 16.09.2015 um 11:22 schrieb Stefan Scheiber:
> Hi,
>
> I need to execute a CDO Query (CDO OCL) on a view with a timestamp (not latest).
> However, I get ObjectNotFoundExceptions for Objects that are present in latest but missing in my view. My question is,
> if this is a bug or am I doing something wrong?
>
> Below is my code:
>
> CDONet4jSession session = ...
> CDOCommitHistory history = session.getCommitInfoManager().getHistory();
> CDOCommitInfo commitInfo = history.getElement(1); // getting the previous commit
> CDOView view = session.openView(commit.getBranch(), commit.getTimeStamp());
> CDOQuery query = view.createQuery("ocl", "Book.allInstances()", null);
> List<Book> books = query.getResult(Book.class);
>
>
> after the first commit i have the books with OID 4 and OID 5 (the result I'm expecting)
> after the second commit i have the books with OID 9 and OID 10 (the books 4 and 5 were removed)
> I get the error that Object with OID 9 cannot be found in view. That is correct, however, the query should not fail
> but deliver the correct answer OID4 and OID5.
>
> The same code works if I make the query on the latest snapshot, i.e. if I fetch the latest commit
>
> CDOCommitInfo commitInfo = history.getFirstElement(); // getting the latest commit
>
> Of course, in this case the result is OID9 and OID10.
>
> Thanks,
> Stefan


Re: [CDO] query on a view other than latest [message #1710974 is a reply to message #1710707] Mon, 12 October 2015 06:00 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.10.2015 um 16:45 schrieb Eike Stepper:
> [...] And it passes successfully.
Correction: It only passes successfully with the MEMStore, but not with the DBStore. I've found and fixed the bug:

479531: [DB] OCL query returns incorrect result in audit views
https://bugs.eclipse.org/bugs/show_bug.cgi?id=479531

Cheers
/Eike

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


Re: [CDO] query on a view other than latest [message #1711466 is a reply to message #1710974] Fri, 16 October 2015 10:23 Go to previous message
Stefan Scheiber is currently offline Stefan ScheiberFriend
Messages: 18
Registered: February 2015
Junior Member
Thanks for your reply!

However, my code fails also with a H2 mem db. (or do you mean something different with MEMStore?)
I'll check it out with the fix. If it still fails I will push my code onto github and post a link here. maybe I'm doing something wrong.

thank you and best regards
stefan
Previous Topic:Disable generation of validation package from Xcore
Next Topic:[CDO] Unable to login with security enabled
Goto Forum:
  


Current Time: Thu Apr 25 17:54:14 GMT 2024

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

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

Back to the top