Hibernate - How to persist only the parent, keeping the children as they are

前端 未结 3 843
我寻月下人不归
我寻月下人不归 2020-12-09 12:57

Can someone please help me understand how to configure hibernate to do what i want.

I have a parent entity \"Appartment\" with a List of \"Room\"s as children. I hav

3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-09 13:37

    Instead of using persistent entities, consider using DTOs (you can call them a page model in the case of web pages). They can give you a flexibility to depict information you want and show it in the format you want. But you should pay for this - you're adding new classes to your system and you have to come up with a way to transform entities to DTOs and backward.

提交回复
热议问题