NHibernate 2 FK与一对一的PK相同(NHibernate 2 FKs to same PK in one-to-one relationship)
我在信封和交易之间有一对一的关系。 我使用主键关联映射它,如下所示:
<class name="Envelope" table="T_ENVELOPE"> <id name="EnvelopeId" column="ENVELOPE_ID"><generator class="identity"/></id> <one-to-one class="Transaction" cascade="all" name="Transaction" /> </class> <class name="Transaction" table="T_TRANSACTION"> <id name="TransactionID" column="TRANSACTION_ID" type="long"><generator class="foreign"><param name="property">Envelope</param></generator></id> <one-to-one name="Envelope" class="Envelope" constrained="true" /> </class>
这很好用,但我的情况很复杂,因为
T_TRANSACTION
有2个FK,它们都映射到T_ENVELOPE's PK (ENVELOPE_ID): TRANSACTION_ID
(如上所示)和OLD_DEPRECATED_TXN_ID
。 所以,我在T_ENVELOPE
中有2个具有完全相同值(信封的id)的T_ENVELOPE
。 如何使NHibernate不仅在TRANSACTION_ID
保存ENVELOPE_ID
,还在OLD_DEPRECATED_TXN_ID
保存ENVELOPE_ID
?我希望我没有这个要求,但我正在处理遗留代码模式和代码。 我知道我也可以这样做:
- envelope.Save //这将保存信封和交易的交易ID,但不保存OLD_DEPRECATED_TXN_ID
- envelope.transaction.old_deprecated_txn_id = envelope.id
- envelope.Save但是,这导致一次插入和一次更新。 我该如何只进行一次插入?
这是一个例子:
T_ENVELOPE ---------- ENVELOPE_ID 1 9 121 T_TRANSACTION ------------- TRANSACTION_ID | OLD_DEPRECATED_TXN_ID 1|1 9|9 121|121
I have a one-to-one relationship between an Envelope and a Transaction. I mapped it using a primary key association as below:
<class name="Envelope" table="T_ENVELOPE"> <id name="EnvelopeId" column="ENVELOPE_ID"><generator class="identity"/></id> <one-to-one class="Transaction" cascade="all" name="Transaction" /> </class> <class name="Transaction" table="T_TRANSACTION"> <id name="TransactionID" column="TRANSACTION_ID" type="long"><generator class="foreign"><param name="property">Envelope</param></generator></id> <one-to-one name="Envelope" class="Envelope" constrained="true" /> </class>
This works fine, but my case is complicated since
T_TRANSACTION
has 2 FKs that both map toT_ENVELOPE's PK (ENVELOPE_ID): TRANSACTION_ID
(as shown above) andOLD_DEPRECATED_TXN_ID
. So, I have 2 FKs inT_ENVELOPE
that have the exact same value (the envelope's id). How can I make NHibernate saveENVELOPE_ID
not just inTRANSACTION_ID
but also inOLD_DEPRECATED_TXN_ID
as well?I wish I didn't have this requirement, but I'm dealing with legacy code schemas and code. I know I can also do something like:
- envelope.Save // this saves Envelope and Transaction's transaction ID but not OLD_DEPRECATED_TXN_ID
- envelope.transaction.old_deprecated_txn_id = envelope.id
- envelope.Save But, that results in one insert and one update. How do I do a one insert only?
Here's an example:
T_ENVELOPE ---------- ENVELOPE_ID 1 9 121 T_TRANSACTION ------------- TRANSACTION_ID | OLD_DEPRECATED_TXN_ID 1|1 9|9 121|121
原文:https://stackoverflow.com/questions/16095903
最满意答案
另一个选项是您可以使用jquery代码删除创建者和创建日期。 您需要做的是将以下代码放在您的列表中的CEWP中。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { $("td[id='onetidinfoblock1']").remove(); $("td[id='onetidinfoblock2']").remove(); }); </script>
The other option is you can remove created by and date of creation using jquery code. You need to do is to put below code in CEWP on your list from.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script language="javascript" type="text/javascript"> $(document).ready(function () { $("td[id='onetidinfoblock1']").remove(); $("td[id='onetidinfoblock2']").remove(); }); </script>
相关问答
更多-
您可以简单地使div runat =“server”并在代码中显示隐藏。
在屏幕大小上隐藏div id(Hide div id on screensize)[2022-08-04]
您目前正在使用min-device-width: 997px ,这意味着如果屏幕尺寸大于#div_1则应隐藏#div_1 997px 。 您应该使用(max-width : 997px)并将@media-query放在样式表的末尾。 将此代码添加到样式表: #DIV_1 { display: block; box-sizing: border-box; color: rgb(51, 51, 51); cursor: default; height: auto ...另一个选项是您可以使用jquery代码删除创建者和创建日期。 您需要做的是将以下代码放在您的列表中的CEWP中。