GithubHelp home page GithubHelp logo

Comments (16)

vineey avatar vineey commented on June 12, 2024 1

@PatrickHuetter will add this scenario in my test cases

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024 1

@PatrickHuetter I found the issue. I have to create a separate join builder for @DBRef fields.

querydsl/querydsl#113

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024 1

@PatrickHuetter Hi Pat, FYI this will be included in 3.0.0 release, which includes major refactoring.
We are going to split querydsl into two separate modules, one for Mongodb and another for JPA for modularity and maintainability. Also we are going to make it easier to use the api via DSL factory style to shield user from different ContextBuilder and Visitor implementations. Just have to pass the rql string and parameters on the same DSL api. Please bear with me.
Thanks for your feedback.

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024 1

@PatrickHuetter This is in progress now

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

I'm not sure if i understand you. There is no relational association existing in mongodb. Basically, using spring-data-mongodb, you can only query in a single collection at a time. But it does allow json like query, like querying against nested fields.

With regards to your model, make sure the mongodb collection for ITEM really contains document with category data, such as:


{
   itemName: 'Some Item Name',
   otherItemAttributes: ... 
   category : {
       id : 1
   }
} 

from archelix-rsql.

PatrickHuetter avatar PatrickHuetter commented on June 12, 2024

That sounds good, so i could query for the category id. The problem is, i'm using DBref for the category, so the underlying Item document looks like this:

{
"itemName": "Some Item Name",
 "category" : DBRef("category", ObjectId("57b85e9ec9e77c000169d3fa"))
}

How can i query this?

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

Checking on some reference, this is possible with querydsl, please check this link

http://stackoverflow.com/questions/33211645/spring-data-mongo-how-to-query-by-dbref-fields-id

You just have to annotate category field by @DBRef. The generated Q class should be able to identify and support this automatically.

The querydsl github issue ticket for this one was this, querydsl/querydsl@350a1a4

The Spring Data issue ticket for this can be found here, https://jira.spring.io/browse/DATAMONGO-825

Please let me know if it works.

from archelix-rsql.

PatrickHuetter avatar PatrickHuetter commented on June 12, 2024

That would be very cool! 👍

from archelix-rsql.

PatrickHuetter avatar PatrickHuetter commented on June 12, 2024

Hi @vineey, is there something new on this? I would be glad to hear from you.

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

@PatrickHuetter Sorry man, little busy with my work lately. Hope to finish the refactoring and DSL builder this weekend. By then, I can proceed with Mongodb @DBRef feature. I can also delegate the other feature to the others who are available to help.

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

@PatrickHuetter @pacitu upon checking different use cases, we have limitations and issues. Since querydsl uses joins on predicates for DBRef, this means we have to split rql filter expressions and separate those refer to DBRef from those that refers to the original collection.

From querydsl issue, querydsl/querydsl#113

@Test
public void Double2() {
    assertEquals("Mike", where()
            .join(user.friend(), friend).on(friend.firstName.eq("Mary"))
            .join(user.enemy(), enemy).on(enemy.firstName.eq("Ann"))
            .singleResult().getFirstName());
}

If we have,

class Name {
  private Long id;

 private String firstname;
 private String middlename;
 private String lastname;
}

class Account {

  private String username;

  @DBRef
  private Name name;
}

We can't do this,

(account.username == 'Jo*' or account.name.firstname == 'John') and (account.username == 'Smith' or account.name.lastname == 'Smith')

So the limitation is we can't do combination of AND/OR logical expression between DBRef field predicate and the original collection field predicate. This means its either we use only DBRef fields as predicates or vice versa. Is it clear?

Do you think this is enough or do you have any suggestion.

from archelix-rsql.

PatrickHuetter avatar PatrickHuetter commented on June 12, 2024

I hope that i've understand that correctly. So it would be possible to query by identifier (equal)?

For example:
product.category == ObjectId('asdafsfgdfgdfsgdsfgfd...') or similar? while category within product is annotated with @DBRef.

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

@PatrickHuetter Yup it is possible. But the problem lies if we mix it with other expressions like

product.id == 1 or product.category.id ==2.

The first one may be represented

where(QProduct.product.id.eq(1)).

then the second one with the DBRef can be represented as,

where()
.join(QProduct.product.category, QCategory.category).on(category.id.eq(1))

So the problem is how can we represent the OR, remember the complete expression is

product.id == 1 or product.category.id ==2.

This is the problem we are facing given the nature of MongoDB.

from archelix-rsql.

PatrickHuetter avatar PatrickHuetter commented on June 12, 2024

@vineey At first it would be a step further if only one part of the expression would work but i can't get either of them working. How should the expression look like? I can't query by mongodb id. I already tested id==57547374c9e77c000109a005 and id==ObjectId("57547374c9e77c000109a005") and so on. None of them returns a positive result set although the object with the given id exists in the database/collection. Which version of the library should i use?

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

@PatrickHuetter nope its not yet implemented. Expression for DBRef needs a new implementation by using querydsl join. I am just showing the possible issues if we continue implementing it. This feature seems impossible to be implemented correctly due to mongodb's limitation, there no possibke workarounds. It is not meant for this one.

from archelix-rsql.

vineey avatar vineey commented on June 12, 2024

@PatrickHuetter I believe, you just have to create a workaround.

from archelix-rsql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.