I am trying to refactor my monolith app to modular monolith. Everything goes smooth until I faced this. (I am not using Spring modulith for now because 1st I want to slice everything in independent modules then I will add it).
I have 2 Entity classes which belongs to 2 different modules:
Module Task: Task entity
Module Space: Space entity
@Table(name = "tasks", schema = "public")
public class Task {
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "space_id", nullable = false)
private Space space;
//rest of the code
So I shouldn't have access to Space class in Task module because Space doesn't belong to Task module. How should I resolve this? I need to have this @ManyToOne relationship with Space in Task. Should I create new Space entity in Task module or? How are you guys solving those issues?