Implement nested Struct field comparison aggregate filtering

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      For the following testing case:

       

      @SessionFactory(exportSchema = false)
      @DomainModel(annotatedClasses = {
          TestStructNestedFieldQuery.StructHolder.class,
          TestStructNestedFieldQuery.SomeStruct.class
      })
      public class TestStructNestedFieldQuery {
      
          @Test
          void test(SessionFactoryScope scope) {
              scope.inTransaction(session -> {
                  var holder = new StructHolder();
                  holder.id = 1;
                  holder.struct = new SomeStruct();
                  holder.struct.firstName = "John";
                  holder.struct.lastName = "Doe";
                  session.persist(holder);
              });
      
              scope.inTransaction(session -> {
                  var query = session.createSelectionQuery("SELECT s FROM StructHolder s WHERE s.struct.firstName = :firstName", StructHolder.class);
                  query.setParameter("firstName", "John");
                  query.getResultList();
              });
          }
          @Entity(name = "StructHolder")
          @Table(name = "collection")
          static class StructHolder {
              @Id
              int id;
      
              SomeStruct struct;
          }
      
          @Embeddable
          @Struct(name = "someStruct")
          static class SomeStruct {
              String firstName;
              String lastName;
          }
      } 

      currently the translated MQL is as below:

      {"aggregate": "collection", "pipeline": [{"$match": {"unused from MongoAggregateSupport.aggregateComponentAssignmentExpression": {"$eq": {"$undefined": true}}}}, {"$project": {"_id": true, "struct": true}}]} 

      we need to make the $match stage logic correct as:

      {"aggregate": "collection", "pipeline": [{"$match": {"struct.firstname": {"$eq": {"$undefined": true}}}}, {"$project": {"_id": true, "struct": true}}]} 

       

            Assignee:
            Valentin Kavalenka
            Reporter:
            Nathan Xu
            None
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: