Skip to content
Advertisement

Spring boot hibernate complex table relationship works partially

I have following models they have one-to-one and one-to-many and many-to-one relationship. Most of the model are fine except one.

My json data:

JavaScript

Java models:

JavaScript

After inserting data in H2 DB, I can see flowing tables and data.

enter image description here

Car:

enter image description here

Vehicle:

enter image description here

Location:

enter image description here

As you can see all data is fine except Location. It has missing warehouse_id. What did I miss? Also identical code and table relationship between warehouse and car one-to-one works fine. But for location it doesn’t work. I have no idea what was missed.

Advertisement

Answer

Thanks to pringi for asking the question. After pringi’s question I checked my saving method:-

JavaScript

After adding missing 2 line, it is fixed and working fine.

enter image description here

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement