- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以向我建议在以下情况下使用适当的映射:
父表 - AllTransactions
子表 - TranCategory1、TranCategory2 和 TranCategory3 以及另外 8 个。
所有十二个表共享相同的组合键。现在 AllTransactions 中的计数是所有子表中事务的总和。子表仅包含父表中的唯一值。
我正在使用的映射如下所示。
我在父表中使用 constrained="true"只是为了避免在父表的 Select 语句中形成连接。但我想我违反了“约束”一词的定义,该定义指定对于 AllTransactions 中的每个事务,TranCategory1 中必须有一个事务。但实际上我的设计恰恰相反。那么我该如何修改我的映射以复制正确的行为并避免使用连接呢?
更新:我当前的映射在连接父表和子表时出错。请帮助我修改映射,以便我可以对上述表执行连接。
完成映射
Parent Table Mapping
<composite-id name="Key" class="AccountEventKey">
<key-property name="TransactionId" column="TRANSACTION_ID" type="long"/>
<key-property name="PartitionMonthNum" column="PARTITION_MONTH_NUM" type ="int"/>
</composite-id>
<many-to-one name="RefAuditQueue" class="RefAuditQueue">
<column name="AUDIT_QUEUE_ID" not-null ="true"/>
</many-to-one>
<many-to-one name="RefAuditRule" class="RefAuditRules">
<column name="AUDIT_RULE_ID" not-null ="false"/>
</many-to-one>
<many-to-one name="AccountDailyInfo" class="AccountDailyInfo">
<column name="ACCOUNT_ID" length="19" not-null ="false"/>
<column name="ACCOUNT_INFO_PROCESSING_DATE" not-null="false"/>
</many-to-one>
<one-to-one name="DisclosureGroupChange" class="DisclosureGroupChanges" constrained="true"/>
<bag name="AuditReviewAssignmentList" table="AUDIT_REVIEW_ASSIGNMENT" generic="true" inverse="true" cascade="save-update" lazy="true" >
<key>
<column name="TRANSACTION_ID" sql-type="long" not-null ="true"/>
<column name="PARTITION_MONTH_NUM" sql-type="int" not-null ="true"/>
</key>
<one-to-many class="AuditReviewAssignment"/>
</bag>
<property name="RacfId" type="string" not-null="false">
<column name="RACFID" length="7"/>
</property>
<property name="EmployeeDailyAssignmentKey" type="long" not-null="false">
<column name="EMP_DAILY_ASSIGNMENT_KEY"/>
</property>
<property name="AuditReviewRequiredInd" type="YesNo" not-null="false">
<column name="AUDIT_REVIEW_REQUIRED_IND"/>
</property>
<property name="TransactionAmount" type="long" not-null="false">
<column name="TRANSACTION_AMOUNT"/>
</property>
<property name="TransactionDate" type="Timestamp" not-null="false">
<column name="TRANSACTION_DATE"/>
</property>
<property name="LastModifiedDate" type="Date" not-null="false">
<column name="LAST_MODIFIED_DATE"/>
</property>
<property name="FirstAddedDate" type="Date" not-null="false">
<column name="FIRST_ADDED_DATE"/>
</property>
<property name="AccountReferenceNum" type="string" not-null="false">
<column name="ACCOUNT_REFERENCE_NUM" length="50"/>
</property>
<property name="CcaEtlRunNum" type="long" not-null="true">
<column name="CCA_ETL_RUN_NUM"/>
</property>
1 Child Table Mapping (There are 10 more child tables)
<composite-id name="Key" class="AccountEventKey">
<key-property name="TransactionId" column="TRANSACTION_ID" type="long"/>
<key-property name="PartitionMonthNum" column="PARTITION_MONTH_NUM" type ="int"/>
</composite-id>
<many-to-one name="AccountEvent" class="AccountEvent" insert="false" update="false" unique="true">
<column name="TRANSACTION_ID"/>
<column name="PARTITION_MONTH_NUM"/>
</many-to-one>
<property name="FrDisclosureGrpName" type="string" not-null="false">
<column name="FR_DISCLOSURE_GRP_NAME" length="8"/>
</property>
<property name="ToDisclosureGrpName" type="string" not-null="false">
<column name="TO_DISCLOSURE_GRP_NAME" length="8"/>
</property>
<property name="LastModifiedDate" type="Date" not-null="false">
<column name="LAST_MODIFIED_DATE=" />
</property>
<property name="FirstAddedDate" type="Date" not-null="false">
<column name="FIRST_ADDED_DATE" />
</property>
<property name="CcaEtlRunNum" type="long" not-null="true">
<column name="CCA_ETL_RUN_NUM" />
</property>
导致错误的连接查询
var query1 = _ses.CreateCriteria<AccountEvent>().CreateAlias("DisclosureGroupChange", "discGrp", NHibernate.SqlCommand.JoinType.InnerJoin).List<AccountEvent>()
异常信息是:
"ORA-00923: FROM keyword not found where expected\n"
异常信息中显示的SQL语句
SELECT this_.TRANSACTION_ID as TRANSACT1_15_1_, this_.PARTITION_MONTH_NUM as PARTITION2_15_1_, this_.AUDIT_QUEUE_ID as AUDIT3_15_1_, this_.AUDIT_RULE_ID as AUDIT4_15_1_, this_.ACCOUNT_ID as ACCOUNT5_15_1_, this_.ACCOUNT_INFO_PROCESSING_DATE as ACCOUNT6_15_1_, this_.RACFID as RACFID15_1_, this_.EMP_DAILY_ASSIGNMENT_KEY as EMP8_15_1_, this_.AUDIT_REVIEW_REQUIRED_IND as AUDIT9_15_1_, this_.TRANSACTION_AMOUNT as TRANSAC10_15_1_, this_.TRANSACTION_DATE as TRANSAC11_15_1_, this_.LAST_MODIFIED_DATE as LAST12_15_1_, this_.FIRST_ADDED_DATE as FIRST13_15_1_, this_.ACCOUNT_REFERENCE_NUM as ACCOUNT14_15_1_, this_.CCA_ETL_RUN_NUM as CCA15_15_1_, discgrp1_.TRANSACTION_ID as TRANSACT1_52_0_, discgrp1_.PARTITION_MONTH_NUM as PARTITION2_52_0_, discgrp1_.FR_DISCLOSURE_GRP_NAME as FR3_52_0_, discgrp1_.TO_DISCLOSURE_GRP_NAME as TO4_52_0_, discgrp1_.LAST_MODIFIED_DATE= as LAST5_52_0_, discgrp1_.FIRST_ADDED_DATE as FIRST6_52_0_, discgrp1_.CCA_ETL_RUN_NUM as CCA7_52_0_ FROM CCAPRD1O_AT.ACCOUNT_EVENT this_ inner join CCAPRD1O_AT.DISCLOSURE_GROUP_CHANGES discgrp1_ on this_.TRANSACTION_ID=discgrp1_.TRANSACTION_ID and this_.PARTITION_MONTH_NUM=discgrp1_.PARTITION_MONTH_NUM
好吧,我可以确认只有当我在 AccountEvent 表中添加 DisclosureGroupChanges 的映射时才会出现此消息。首先,我在遇到错误时避免了此映射。但现在我需要在这些表之间执行连接,据我所知,我们只能对 NHibernate 中的相关表进行连接。如果我在这里错了,请纠正我。
最佳答案
我弄错了。
子表中的一个映射的值为“LAST_MODIFIED_DATE=”。这总是导致我出错。
关于c# - 对 NHibernate 中一对一映射的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5569551/
我一直在为初学者阅读 nhibernate 3.0 并阅读了一些常见错误(我犯了一些错误) 我想知道将一个或多个记录设为只读有哪些策略。现在我取回所有行并循环遍历它们,使它们通过 session.Re
我们有一个使用 NHibernate 的相当健壮的系统,我们正在从单个数据库服务器迁移到拥有两台服务器,一台用于管理,另一台用于我们面向公众的网站。这主要是为了让我们可以使用不会影响当前站点的工作流来
我在尝试构建一个时遇到以下错误 session 工厂: PersistenceTests.Can_Map_Orders_To_Database : Failed System.IndexOutOfRa
如果客户有很多订单附加到他们。您将如何使用 NHibernate 延迟加载订单列表。 是不是需要设置映射文件?任何帮助或示例都会很棒。 最佳答案 Chris 的建议是我会怎么做,但是如果您想在运行时执
我正在尝试使用 HQL 对一个简单的查询进行分页,并将总行数作为同一查询的一部分进行检索。 我的查询很简单... var members = UnitOfWork.CurrentSession.Cre
我有旧版数据库,存储的日期表示无日期为9999-21-31, 列Till_Date的类型为DateTime not-null="true"。 在应用程序中,我要构建持久化类,将no-date表示为nu
您可以指定命名空间和程序集以使用 HBM 文件顶部的类型: 您可以在同一个映射文件中使用来自多个程序集/命名空间的类型,如果可以,这样做的语法是什么? 最佳答案 您可以从 HBM 文件的顶部删除默认
如何强制 NHibernate 在多对多集合上执行 RIGHT 外连接或 INNER 连接而不是 LEFT 外连接? 我想这样做的原因是因为过滤应用于集合元素。使用左连接,您将获得与未过滤查询相同的返
我们开始在我的工作场所使用NHibernate,包括从映射生成模式。我们的DBA想要的一件事是主键和外键关系的名称一致。我已经能够设置FK约束名称,但是在的文档中看,它似乎不存在命名主键约束的方法。
我需要NHibernate来执行这样的查询: SELECT * FROM Users ORDER BY Func(FirstName, LastName) Standart NHibernate Or
假设在一个实体中有属性 id、用户名、年龄、地址。现在我只想要 id 和 username 并使用此代码。 投影可以从查询中返回实体列表以外的内容。 var proj = Projections.Pr
我花了很长时间,但我终于让 nHibernate 的 Hello World 工作了。在我做了“延迟加载”之后它起作用了。老实说,我无法告诉您为什么这一切都有效,但确实如此,现在我正在阅读您不需要延迟
假设您有两个类,Person 和 Address。 Person 有一个对 Address 的引用,如下所示: public class Person { public virtual Addre
我在 NHibernate 引用文档 中阅读第 10 章“只读实体”如下: http://nhibernate.info/doc/nh/en/index.html#readonly 但不幸的是我不知道
有谁知道 NHibernate 是否支持从存储过程返回输出参数?我在文档中进行了搜索,但无法真正找到任何可以确认的内容。 最佳答案 我面临同样的问题。 NHibernate 不允许您以这种方式使用存储
简而言之,什么工作得更快: SessionFactory 预编译 XML 配置,或 流畅的NHibernate提供 以编程方式配置? 最佳答案 我个人的经验是,Configuration 对象的构建(
我的域类具有如下所示的集合: private List _foos = new List(); public virtual ReadOnlyCollection Foos { get { retur
当我有一个带有一对多子集合的实体对象时,我需要查询一个特定的子对象,是否有我还没有想出的功能或一些巧妙的模式来避免 NHibernate获取整个子集合? 例子: class Parent {
在我的域中,员工和部门具有一对多的双向关系;为了让子员工同步这个,我有一个“内部”访问字段,用于部门中员工的集合(NHibernate 的 Iesi),否则它将是只读公共(public)的。像这样:
我有一个 nhibernate 自定义类型,我想用 Fluent NHibernate 映射它。 HBM 映射如下所示。 Services.Data.DateConventionTyp
我是一名优秀的程序员,十分优秀!