I have a class structure something like below:
public class X {
@Id
private Long id;
//One to one mapping
private Y y;
....Some more attibutes
}
public class Y {
@Id
private Long id;
//ManyToOne mapping
private Z z;
....Some more attibutes
}
public class Z {
@Id
private Long id;
....Some more attibutes
}
Now I have a Respository interface like below
public interface XRepository extends JPARepository<X, Long> {
// This is not working,
public X findByIdAndYIdAndZId(Long xId, Long yId, Long zId);
//This also doesn't work obviously for same reason as above one
public X findYIdAndZId(Long yId, Long zId);
}
I am getting this exception
org.springframework.data.mapping.PropertyReferenceException: No property zId found for type X!
Please help me on how to construct the method for such scenario