mercredi 1 septembre 2021

Path to the nested field java reflection

I have a question. How can I get an array of field paths, e.g. foo.bar.name, foo.bar.id, foo.id, etc using reflection? I know I have to use recursion, but what's the best way to use it? Entities:

public class Foo {
private Long id;

@ManyToOne
private Bar bar;
//getter, setter
}

public class Bar {

private Long id;
private String name;

}




Aucun commentaire:

Enregistrer un commentaire