Map partitioned table with partition discriminator column

痞子三分冷 提交于 2020-01-03 05:26:07

问题


I have a legacy Oracle 10g database. This database has a table ITEMDELIVERY with a column DELIVERY_DATE. The table is partitioned by this column. Because of that, the primary key of this table is a compound one involving the columns ITEMDELIVERY_ID and DELIVERY_DATE.
There is another table ITEMDELIVERYDETAIL having a FK to ITEMDELIVERY. To be able to benefit from the partitioning and to be able to be partitioned itself, this table has a column PARTITION_DATE. ITEMDELIVERY_ID and PARTITION_DATE form the FK to ITEMDELIVERY.

PARTITION_DATE has no business meaning in ITEMDELIVERYDETAIL and is there only for technical reasons. Because of this, I would like to avoid specifying this column in my entity.
I tried the following in an implementation of IAutoMappingOverride<ItemDeliveryDetail>:

mapping.Map(x => x.ItemDelivery.DeliveryDate).Column("PARTITION_DATE");

But this didn't work, I get the following exception:

NHibernate.PropertyNotFoundException: Could not find a getter for property 'DeliveryDate' in class 'Domain.ItemDeliveryDetail'

Is there any way to achieve my goal?


回答1:


i think the answer to this question is using a Reference to ItemDelivery in ItemDeliveryDetail you showed in another question.

mapping.References(x => x.ItemDelivery)
    .Columns("ITEMDELIVERY_ID", "PARTITIONDATE");

this makes it invisible, automaticly filled and the Reference to its parent is sane




回答2:


In "classic" NHibernate I once solved a similar issue by adding access="private" to a property mapping. This tells NHibernate to map to a private member variable which, thus, is invisible to rest of the model.

Fluent NHibernate has a solution for this that in their own words is not ideal, but it does support the feature.




回答3:


If you are not interested in have it in your domain, why are you mapping it? If you want to map the property of the Item, then add it to the ItemDelivery class mapping



来源:https://stackoverflow.com/questions/8475685/map-partitioned-table-with-partition-discriminator-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!