12

I have issues trying to access nested object when using BooleanBuilder. I have read that the default is 2 levels, but for my use case, I need to access 3rd level nested objects. So I have added @QueryInit as pointed out in many other answers. But I still cannot access it. Here is my code:

@Document
public class Order implements Serializable {

     @QueryInit(*.*)
     private Item item;

}

public class Item implements Serializable {
   private Details details;
}

public class Details implements Serializable {
   private String name;
}

public static BooleanExpression name(String name) {
  QOrder order = QOrder.order;
  return order.item.details.name.eq(name)
}

I have QOrder, QItem classes generated and working fine. But details.description gives error because QDetails class was not generated. How do I make it generate QDetails?

1
  • 1
    Did you find the solution?
    – Yubaraj
    Commented Jun 16, 2021 at 17:13

1 Answer 1

0

The first problem I see is that you missed a semicolon on the return statement which might be causing you some other issues. The way to generate QDetails is to first reference the query, and request the details from the assigned result.

1
  • Could you elaborate what you mean by referencing the query?
    – aksh1618
    Commented Jul 19, 2020 at 17:29

Not the answer you're looking for? Browse other questions tagged or ask your own question.