Hibernate Mapping Two Tables to One Class

前端 未结 4 1532
梦毁少年i
梦毁少年i 2020-12-09 23:40

I need to map two tables to a single class, having trouble figuring this out. One table is ROOMS, the other is TRAINERS.

The ROOMS table:

OOC_UNIT         


        
4条回答
  •  忘掉有多难
    2020-12-09 23:57

    In my experience simplicity is key when using any ORM including Hibernate. I would create a database view based on your SQL lets call that TRAINERS_ROOMS then simple map that database view to a new Java object lets call that TrainersRooms.

    You get simple easy to manager hibernate mappings, but of course you can perform any updates using this new object so if you need that, this solution won't work out for you.

提交回复
热议问题