I asked a question earlier, but think it wasn\'t clear enough i will elaborate further with the code.
I have a Teacher entity and Department entity
Many Teachers
This is not a JPA problem, but is caused by recursive instantiation of Teacher
/Department
.
When you create, or ask JPA to create, an instance of Teacher
, the Teacher
attempts to instantiate a Department
, which instantiates a Teacher
..., to infinity.
Hence you're seeing a StackOverflowError
error near the end of that stack trace.
Remove the = new Teacher()
and = new Department()
expressions from the class definition; depend on and use appropriate setter methods when you create them.