I have below collection and embedded documents
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Document(collection = "person_details")
public class PersonDetails {
@MongoId(FieldType.OBJECT_ID)
private String managerId;
.
.
@QueryInit("addressDetails.*")
private List<ContactDetails> contactDetails;
.
}
And ContactDetails.java looks like below:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContactDetails {
private AddressDetails addressDetails;
private StateDetails stateDetails;
}
StateDetails look like below:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
@Document(collection = "statedetails")
public class StateDetails {
@MongoId(FieldType.OBJECT_ID)
private String stateId;
private String stateName;
}
And AddressDetails look like below:
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AddressDetails {
private String address;
@Field(targetType = FieldType.STRING)
private AddressTypeEnum addressType;
}
After building, I am not getting Q class for AddressDetails, due to which I am facing issues in building Predicate. Below is my generated QPersonDetail class
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QPersonDetails extends EntityPathBase<PersonDetails> {
private static final long serialVersionUID = 184263140L;
private static final PathInits INITS = new PathInits("*", "contactDetails.addressDetails.*");
public static final QPersonDetails managerDetails = new QPersonDetails("managerDetails");
public final ListPath<ContactDetails, QContactDetails> contactDetails = this.<ContactDetails, QContactDetails>createList("contactDetails", ContactDetails.class, QContactDetails.class, INITS.get("contactDetails"));
public QPersonDetails(String variable) {
this(PersonDetails.class, forVariable(variable), INITS);
}
public QPersonDetails(Path<? extends PersonDetails> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}
public QPersonDetails(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}
public QPersonDetails(PathMetadata metadata, PathInits inits) {
this(PersonDetails.class, metadata, inits);
}
}
And below is generated QContactDetails:
@Generated("com.querydsl.codegen.DefaultEmbeddableSerializer")
public class QContactDetails extends BeanPath<ContactDetails> {
private static final long serialVersionUID = 1039545873L;
private static final PathInits INITS = PathInits.DIRECT2;
public static final QContactDetails contactDetails = new QContactDetails("contactDetails");
public final SimplePath<AddressDetails> addressDetails = createSimple("addressDetails", AddressDetails.class);
public QContactDetails(String variable) {
this(ContactDetails.class, forVariable(variable), INITS);
}
public QContactDetails(Path<? extends ContactDetails> path) {
this(path.getType(), path.getMetadata(), PathInits.getFor(path.getMetadata(), INITS));
}
public QContactDetails(PathMetadata metadata) {
this(metadata, PathInits.getFor(metadata, INITS));
}
public QContactDetails(PathMetadata metadata, PathInits inits) {
this(ContactDetails.class, metadata, inits);
}
}
I referred many threads including https://querydsl.com/static/querydsl/5.0.0/reference/html/ch03s03.html but still not able to figure out issue. Even i tried with
@QueryInit("*.*")
annotation on contactDetails, above. Any idea, where I am missing. I dont want AddressDetails to be annotated as @Document.
I found this thread Querydsl 4 StringExpression of a field inside a SimplePath This solves theproblem, but I am still confused with the concept, how @QueryEmbeddable works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.