I have an existing data scheme I'm reluctant to change. There are two entities/tables: parent
and child
, with parent
having the foreign key column child_id
. It's a 1-to-1 relationship.
The problem is: the magic behind the scenes expects the child table to have the foreign key column (the exception mentions a ...JOIN ON child.parent = parent.id
). Is it possible to inverse this to match the existing scheme? (I know it is with hibernate, but I'd like to stay with JDBC).
Relevant code:
@Repository
public interface ParentRepository extends CrudRepository<Parent, Long>{
}
@Data
public class Parent {
@Id
private Long id;
private Child child;
}
@Data
public class Child {
@Id
private Long id;
}
Somewhat related question: Spring Data JDBC invert OneToMany navigation