How to map an interface in nhibernate?

前端 未结 3 363
不知归路
不知归路 2020-12-19 06:17

I\'m using two class NiceCustomer & RoughCustomer which implment the interface ICustomer.

The ICustomer has f

3条回答
  •  Happy的楠姐
    2020-12-19 06:38

    It is not possible to map an interface in nhibernate. If your goal is to be able to query using a common type to retrieve both types of customers you can use a polymorphic query. Simply have both your classes implement the interface and map the classes normally. See this reference:

    https://www.hibernate.org/hib_docs/nhibernate/html/queryhql.html (section 11.6)

提交回复
热议问题