Spring数据,通过嵌套对象的属性查找

时间:2019-04-08 18:01:44

标签: java spring spring-boot spring-data-jpa spring-data

我有以下代码:

@Entity
public class StudentEntity {
    @Id
    private String id;
    private Student student;
    ...
}


public class Student {
    private String name;
    private List<Grade> grades;
}


public class Grade {
    private String className;
    private String grade;
}

我已经建立了一个Spring数据mongodb存储库,我正在尝试创建一个方法,该方法将基于我作为参数传递的List<Student>返回一个className。根据我读过的所有内容,我认为以下方法会起作用:

public List<Student> findByStudentGradesClassName(final String className);

但是给出一个错误,指出参数类型应该是Grade对象。我真的只想传递String className

这可能吗?

1 个答案:

答案 0 :(得分:3)

您必须使用下划线分隔嵌套字段:

ThisWorkbook.Activate
Sheet1.Activate

Dim i As Long
Dim theColumn As Long
Dim LastCell As Long
LastCell = Range("b" & Rows.Count).End(xlUp).Row
Range("H2:H" & Cells(Rows.Count, "h").End(xlUp).Row).ClearContents
i = 1
Do

i = i + 1
For theColumn = 2 To 6
    Dim higher As Boolean
    higher = Cells(i, theColumn).Value - Cells(i, theColumn + 1).Value > 0
    If higher Then Exit For
Next

Cells(i, "H").Value = higher
If i = LastCell Then Exit Do
Loop

MsgBox "Analysis Completed"

请注意,您仍然必须以大写字母开头字段名称。