StockPurchase
我有一个 Fluent NHibernate 基于约定的映射,我的实体和我的实体之间存在多对多关系StockSale
。
我创建了以下约定:
public class ManyToManyLinkedTableConvention : IHasManyToManyConvention
{
public void Apply(FluentNHibernate.Conventions.Instances.IManyToManyCollectionInstance instance)
{
var naming = new NamingStrategy();
if (StringComparer.InvariantCultureIgnoreCase.Compare(instance.EntityType.Name, instance.OtherSide.EntityType.Name) > 0)
{
instance.Table(naming.Quote(
string.Format(
"{0}To{1}",
Inflector.Inflector.Pluralize(instance.EntityType.Name),
Inflector.Inflector.Pluralize(instance.ChildType.Name))));
instance.Not.Inverse();
}
else
{
instance.Inverse();
}
}
}
当我使用 hbm2ddl 函数时,它会完全按照我的需要构建表:
CREATE TABLE "StockSalesToStockPurchases"
(
stocksale_id uuid NOT NULL,
stockpurchase_id uuid NOT NULL,
CONSTRAINT fkee886e07285f29f1 FOREIGN KEY (stockpurchase_id)
REFERENCES "StockPurchases" (stockpurchaseid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fkee886e073b8be3d9 FOREIGN KEY (stocksale_id)
REFERENCES "StockSales" (stocksaleid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
...奇怪的是,它还创建了第二个表:
CREATE TABLE stockpurchasestostocksales
(
stockpurchase_id uuid NOT NULL,
stocksale_id uuid NOT NULL,
CONSTRAINT fk396e0343285f29f1 FOREIGN KEY (stockpurchase_id)
REFERENCES "StockPurchases" (stockpurchaseid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk396e03433b8be3d9 FOREIGN KEY (stocksale_id)
REFERENCES "StockSales" (stocksaleid) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
);
为什么会这样做,我该如何阻止它?