NHibernate One-To-One Mapping

前端 未结 1 763
天涯浪人
天涯浪人 2021-02-07 21:18

I\'m new to NHibernate so have had limited exposure to mappings etc so far, and I\'ve just hit a scenario which I need some help with.

I have 2 tables:

Reviews T

1条回答
  •  醉梦人生
    2021-02-07 21:46

    Ayende has a good explanation for one-to-one mappings here.

    In your case the mappings should probably look like this:

    Review.hbm.xml

    
        
            
            
        
    
        
        
         
    
    
    

    TaggedReview.hbm.xml

    You will most likely need a primary key in the table, because you can't use the same column for the key and the foreign key.

    
        
            
            
        
         
          
        
        
    
    

    If you cannot or do not want to change the db, you can take a look at NHibernate mapping - one-to-one (or one-to-zero).

    0 讨论(0)
提交回复
热议问题