Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for fetch specs defined in the EOModel #20

Open
mariussoutier opened this issue Sep 22, 2011 · 16 comments
Open

Add support for fetch specs defined in the EOModel #20

mariussoutier opened this issue Sep 22, 2011 · 16 comments
Assignees
Labels
Milestone

Comments

@mariussoutier
Copy link

In the EOModel I have a fetch spec defined with the qualifier $patient of type Patient. This auto-generates a method which does:

public static NSArray<net.starhealthcare.sffoundation.model.SFIncident> fetchIncidentsWithDiagnosesForPatient(EOEditingContext editingContext, NSDictionary<String, Object> bindings) {
  EOFetchSpecification fetchSpec = EOFetchSpecification.fetchSpecificationNamed("fetchSpecName", "Incident");
  fetchSpec = fetchSpec.fetchSpecificationWithQualifierBindings(bindings);
  return editingContext.objectsWithFetchSpecification(fetchSpec);
}

I then call it like this:

fetchIncidentsWithDiagnosesForPatient(this.editingContext(), patient);

This does not work with WOUnit, the following exception gets thrown:

com.webobjects.eocontrol.EOQualifier$QualifierVariableSubstitutionException: Error in variable substitution: value for variable $patient not found
at com.webobjects.eocontrol.EOKeyValueQualifier.qualifierWithBindings(EOKeyValueQualifier.java:270)
at com.webobjects.eocontrol.EOQualifier._andOrQualifierWithBindingsAndOptions(EOQualifier.java:719)
at com.webobjects.eocontrol.EOAndQualifier.qualifierWithBindings(EOAndQualifier.java:146)
at com.webobjects.eocontrol.EOFetchSpecification.fetchSpecificationWithQualifierBindings(EOFetchSpecification.java:182)
@hprange
Copy link
Owner

hprange commented Sep 28, 2011

I'm looking into this problem now.

@hprange
Copy link
Owner

hprange commented Sep 28, 2011

What editing context? MockEditingContext or TemporaryEditingContext?

I've written some tests and it worked with MockEditingContext. The TemporaryEditingContext didn't find any object, but it also didn't throw any exception.

@mariussoutier
Copy link
Author

I tried both, didn't work. Have you tried a Fetch Spec with a parameter?

@hprange
Copy link
Owner

hprange commented Sep 29, 2011

Yes, I tried 3 scenarios:

  1. Fetch Spec with a String parameter.
  2. Fetch Spec with a Foo entity parameter.
  3. Fetch Spec with both String and Foo entity parameters.

Maybe I'm missing something? Does Incident or Patient inherit from other entity? What is the kind of relationship between them? To one? To many? Many-to-many?

@mariussoutier
Copy link
Author

To-many, a patient has many incidents, an incident has one patient.
The spec looks like this:
patient = $patient and incidentID = diagnoses.incidentID and (disabled = null or disabled = 'false')

@hprange
Copy link
Owner

hprange commented Oct 16, 2011

Marius,

I've tried to reproduce the same entities and the same relationships in a test model. I'm still unable to reproduce the error on fetchIncidentsWithDiagnosesForPatient on both: MockEditingContext and TemporaryEditingContext.

The same fetchSpecification works in runtime with real editing contexts, right? Looking into the stack trace, it doesn't seem to be a WOUnit problem. :(

@MathieuClusiau
Copy link

Hi, I have similor problem with a fetch specs defined in the EOModel.

My fetch does not return any results when I use MockEditingContext with relationship To many. But if I use ERXEC.newEditingContext() all is ok.

//@Rule
public MockEditingContext editingContext = new MockEditingContext("Core");
//public EOEditingContext editingContext2 = ERXEC.newEditingContext();

//@Dummy   for one book many page
private Book _book;

//@Dummy
private Page _page;

@Test
public void testListeMembreValides() {
    _book = Book.createBook(editingContext); //create 
    _book.setTitle("TestBook");

    _page = Page.createPage(editingContext); //create 
    _page.setEmpty(true);
    _book.addToRelationPage(_page); // this fonction call addObjectToBothSideOfRelationshipWithKey(objet, _book.ClefPages) 

    // This fetch is ok with the MockEditingContext and EOEditingContext
    NSArray<? extends Book> listBook =  Book.fetchBooks(editingContext, Book.QualTitle.contains("TestBook"), null, false);
    assertFalse(listBook.count() == 0);

    // This fetch fails with the MockEditingContext, but works with EOEditingContext
    NSArray<? extends Book> listBook2 =  Book.fetchBooks(editingContext, Book.QualTitle.contains("TestBook").and(Book.QualPages.dot(Page.QualEmpty).isTrue()), null, false);
    assertFalse(listBook2.count() == 0);        
}

@hprange
Copy link
Owner

hprange commented Mar 28, 2012

I'm looking into this problem again.

@hprange
Copy link
Owner

hprange commented Mar 28, 2012

It seems to be a problem in the qualifier evaluation algorithm provided by the core WebObjects classes. I'm writing to the list to ask for advice.

@MathieuClusiau
Copy link

Thanks for your investigation. Let me know when you have solution.

@syrinx2012
Copy link

Hello Henrique,

I was just wondering if there was a fix for this issue? It's definitely a blocker for our development team. Unless there is a workaround?

Thank you.

Martin

@hprange
Copy link
Owner

hprange commented Jun 15, 2013

@syrinx2012 this issue is caused by a bug in the core WebObjects classes. Kieran Kelleher pushed a change to Wonder that I think is supposed to fix this problem or, at least, is related to the problem. You can see the change here:

wocommunity/wonder@ea23f97

I still don't have a work around for this issue. However, I'll try to address this problem after WOWODC.

@syrinx2012
Copy link

Thanks for the information. However, I'm already running version 6.0.4 of Wonder, which include this fix, and the problem still exist. I guess it's caused by something else. Thanks a lot for looking into this!

@MathieuClusiau
Copy link

For your information, I will try to solve this issue this year.

Mathieu

@ghost ghost assigned hprange Jun 23, 2013
@MathieuClusiau
Copy link

Hello Henrique,

I found a solution. I need to put more effort on it to be sure it's a good solution.
I will give you the fix when it's be ready.

note: The problem is in WebObjects and the fix is in Wonder.

Mathieu

@hprange
Copy link
Owner

hprange commented Jul 5, 2013

Mathieu, nice to hear. Just let me know if you need any help.

@hprange hprange modified the milestones: wounit-1.3, wounit-1.3.2 Jul 5, 2020
@hprange hprange modified the milestones: wounit-1.4, wounit-1.5 Sep 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants