Hibernate Mapping Two Tables to One Class

前端 未结 4 1528
梦毁少年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-10 00:12

    Solution I've come up with seems to be working as far as querying data, I haven't tried any insert/update/delete yet.

    I created the TRAINER object to extend the ROOM object.

    public class Trainer extends Room {
      ...
    }
    

    Then I modified the mapping for ROOM to include a joined-subclass:

    
       
           ...
          
          ...
    
          
             
                  
                  ...
             
             
             ...
          
       
     ...
    

    So far it appears to be working.

    Thanks,

    Nick

提交回复
热议问题