如何使用成员实体创建视图实体是另一个视图实体?
How to create view-entity with member-entity is an another view-entity?
我有包含实体 A1(具有字段 A11、A12、...)、A2(具有字段 A21、A22)的视图实体 A 和包含实体 B1、B2 的视图实体 B。然后我想创建视图实体 C,其成员实体是 A 和 B,包括两个实体的所有字段。但是当我在视图实体 C 中使用 find() 方法时,moqui 将生成 SQL 语句,如:
Select A.A1.A11, A.A1.A12, ..... from .....
这使得SQL语句错误。我该如何解决这个问题???
这是我的代码:
<view-entity entity-name="PartyDetail" package="mantle.party">
<member-entity entity-alias="PTY" entity-name="mantle.party.Party"/>
<member-entity entity-alias="PER" entity-name="mantle.party.Person" join-from-alias="PTY" join-optional="true">
<key-map field-name="partyId"/></member-entity>
<member-entity entity-alias="ORG" entity-name="mantle.party.Organization" join-from-alias="PTY" join-optional="true">
<key-map field-name="partyId"/></member-entity>
<alias-all entity-alias="PTY"/>
<alias-all entity-alias="PER"/>
<alias-all entity-alias="ORG"/>
</view-entity>
<view-entity entity-name="UserAccountAndPartyDetail" package="moqui.view">
<member-entity entity-alias="UA" entity-name="moqui.security.UserAccount"></member-entity>
<member-entity entity-alias="PTY" entity-name="mantle.party.PartyDetail" join-from-alias="UA">
<key-map field-name="partyId"></key-map>
</member-entity>
<alias-all entity-alias="UA"></alias-all>
<alias-all entity-alias="PTY"></alias-all>
</view-entity>
而 UserAccountAndPartyDetail 的 SQL 语句是这样的:
select
UA.USER_ID,
UA.USERNAME,
UA.USER_FULL_NAME,
UA.CURRENT_PASSWORD,
UA.RESET_PASSWORD,
UA.PASSWORD_SALT,
UA.PASSWORD_HASH_TYPE,
UA.PASSWORD_BASE64,
UA.PASSWORD_SET_DATE,
UA.PASSWORD_HINT,
UA.HAS_LOGGED_OUT,
UA.DISABLED,
UA.DISABLED_DATE_TIME,
UA.SUCCESSIVE_FAILED_LOGINS,
UA.REQUIRE_PASSWORD_CHANGE,
UA.CURRENCY_UOM_ID,
UA.LOCALE,
UA.TIME_ZONE,
UA.EXTERNAL_USER_ID,
UA.EMAIL_ADDRESS,
UA.PARTY_ID,
PTY.PTY.PSEUDO_ID,
PTY.PTY.PARTY_TYPE_ENUM_ID,
PTY.PTY.EXTERNAL_ID,
PTY.PTY.DATA_SOURCE_ID,
PTY.PTY.GATEWAY_CIM_ID,
PTY.PTY.COMMENTS,
PTY.PTY.HAS_DUPLICATES,
PTY.PTY.LAST_DUP_CHECK_DATE,
PTY.PTY.MERGED_TO_PARTY_ID,
PTY.PER.SALUTATION,
PTY.PER.FIRST_NAME,
PTY.PER.MIDDLE_NAME,
PTY.PER.LAST_NAME,
PTY.PER.PERSONAL_TITLE,
PTY.PER.SUFFIX,
PTY.PER.NICKNAME,
PTY.PER.GENDER,
PTY.PER.BIRTH_DATE,
PTY.PER.DECEASED_DATE,
PTY.PER.HEIGHT,
PTY.PER.WEIGHT,
PTY.PER.MOTHERS_MAIDEN_NAME,
PTY.PER.MARITAL_STATUS_ENUM_ID,
PTY.PER.EMPLOYMENT_STATUS_ENUM_ID,
PTY.PER.RESIDENCE_STATUS_ENUM_ID,
PTY.PER.OCCUPATION,
PTY.ORG.ORGANIZATION_NAME,
PTY.ORG.OFFICE_SITE_NAME,
PTY.ORG.ANNUAL_REVENUE,
PTY.ORG.NUM_EMPLOYEES
from
(
USER_ACCOUNT UA
inner join(
select
PTY.PARTY_ID,
PTY.PSEUDO_ID,
PTY.PARTY_TYPE_ENUM_ID,
PTY.DISABLED,
PTY.EXTERNAL_ID,
PTY.DATA_SOURCE_ID,
PTY.GATEWAY_CIM_ID,
PTY.COMMENTS,
PTY.HAS_DUPLICATES,
PTY.LAST_DUP_CHECK_DATE,
PTY.MERGED_TO_PARTY_ID,
PER.SALUTATION,
PER.FIRST_NAME,
PER.MIDDLE_NAME,
PER.LAST_NAME,
PER.PERSONAL_TITLE,
PER.SUFFIX,
PER.NICKNAME,
PER.GENDER,
PER.BIRTH_DATE,
PER.DECEASED_DATE,
PER.HEIGHT,
PER.WEIGHT,
PER.MOTHERS_MAIDEN_NAME,
PER.MARITAL_STATUS_ENUM_ID,
PER.EMPLOYMENT_STATUS_ENUM_ID,
PER.RESIDENCE_STATUS_ENUM_ID,
PER.OCCUPATION,
ORG.ORGANIZATION_NAME,
ORG.OFFICE_SITE_NAME,
ORG.ANNUAL_REVENUE,
ORG.NUM_EMPLOYEES
from
(
PARTY PTY
left outer join PERSON PER on
PTY.PARTY_ID = PER.PARTY_ID
left outer join ORGANIZATION ORG on
PTY.PARTY_ID = ORG.PARTY_ID
)
) PTY on
UA.PARTY_ID = PTY.PTY.PARTY_ID
)
order by
1 offset 0 rows fetch first 50 rows only
这是控制台中的错误:
Error running groovy script (Error finding list of UserAccountAndPartyDetail by null [42P01]):
1 : import static org.moqui.util.ObjectUtilities.*
2 : import static org.moqui.util.CollectionUtilities.*
3 : import static org.moqui.util.StringUtilities.*
4 : import java.sql.Timestamp
5 : // these are in the context by default: ExecutionContext ec, Map<String, Object> context, Map<String, Object> result
6 : entityDefinition = (ec.entity.getEntityDefinition(selectedEntity))
7 : entityValueList_xafind = ec.entity.find("${selectedEntity}").offset(0).limit(50)
8 :
9 : if (true) {
10 : Map efSfiDefParms = null
11 : entityValueList_xafind.searchFormMap(ec.context, efSfiDefParms, "", "", true)
12 : }
13 : entityValueList = entityValueList_xafind.list()
14 : if (entityValueList_xafind.getLimit() == null) {
15 : entityValueListCount = entityValueList.size()
16 : entityValueListPageIndex = entityValueList.pageIndex
17 : entityValueListPageSize = entityValueListCount > 20 ? entityValueListCount : 20
18 : } else {
19 : entityValueListCount = entityValueList_xafind.count()
20 : entityValueListPageIndex = entityValueList_xafind.pageIndex
21 : entityValueListPageSize = entityValueList_xafind.pageSize
22 : }
23 : entityValueListPageMaxIndex = ((BigDecimal) (entityValueListCount - 1)).divide(entityValueListPageSize ?: (entityValueListCount - 1), 0, BigDecimal.ROUND_DOWN) as int
24 : entityValueListPageRangeLow = entityValueListPageIndex * entityValueListPageSize + 1
25 : entityValueListPageRangeHigh = (entityValueListPageIndex * entityValueListPageSize) + entityValueListPageSize
26 : if (entityValueListPageRangeHigh > entityValueListCount) entityValueListPageRangeHigh = entityValueListCount
27 : // make sure the last statement is not considered the return value
28 : return;
15:34:14.108 ERROR p60559178-15 o.m.i.s.ScreenRenderImpl Error rendering screen [component://tools/screen/Tools/Entity/DataEdit/EntityDataFind.xml]
org.moqui.impl.entity.EntitySqlException: Error finding list of UserAccountAndPartyDetail by null [42P01]
at org.moqui.impl.entity.EntityFindBase.listInternal(EntityFindBase.groovy:1064) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.list(EntityFindBase.groovy:929) ~[moqui-framework-2.1.0.jar:2.1.0]
at component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions.run(component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions:13) ~[script:?]
at org.moqui.impl.actions.XmlAction.run(XmlAction.java:67) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:132) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.doActualRender(ScreenRenderImpl.groovy:761) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.internalRender(ScreenRenderImpl.groovy:569) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.render(ScreenRenderImpl.groovy:147) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.webapp.MoquiServlet.service(MoquiServlet.groovy:95) ~[moqui-framework-2.1.0.jar:2.1.0]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[moqui_temp7467403619005190592execlib_javax.servlet-api-3.1.0.jar.:3.1.0]
at org.moqui.elasticsearch.ElasticRequestLogFilter.doFilter(ElasticRequestLogFilter.groovy:107) ~[moqui-elasticsearch-1.1.0.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: org.postgresql.util.PSQLException: ERROR: invalid reference to FROM-clause entry for table "pty"
Hint: There is an entry for table "pty", but it cannot be referenced from this part of the query.
Position: 1898
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118) ~[postgresql-42.2.2.jar:42.2.2]
at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at org.postgresql.ds.PGPooledConnection$StatementHandler.invoke(PGPooledConnection.java:428) ~[postgresql-42.2.2.jar:42.2.2]
at com.sun.proxy.$Proxy22.executeQuery(Unknown Source) ~[?:?]
at bitronix.tm.resource.jdbc.proxy.PreparedStatementJavaProxy.executeQuery(PreparedStatementJavaProxy.java:102) ~[btm-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.moqui.impl.entity.EntityQueryBuilder.executeQuery(EntityQueryBuilder.java:91) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindImpl.iteratorExtended(EntityFindImpl.java:150) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.listInternal(EntityFindBase.groovy:1063) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.list(EntityFindBase.groovy:929) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.entity.EntityFind$list.call(Unknown Source) ~[?:?]
at component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions.run(component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions:13) ~[script:?]
at org.moqui.impl.actions.XmlAction.run(XmlAction.java:67) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:132) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) [moqui-framework-2.1.0.jar:2.1.0]
at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1487) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:69) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.MethodCall._eval(MethodCall.java:65) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Expression.eval(Expression.java:81) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.accept(DollarVariable.java:59) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.recurse(Environment.java:824) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.RecurseNode.accept(RecurseNode.java:73) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.recurse(Environment.java:824) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.RecurseNode.accept(RecurseNode.java:73) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.VisitNode.accept(VisitNode.java:71) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:326) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:332) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.process(Environment.java:305) [freemarker-2.3.26-incubating.jar:2.3.26]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) [moqui-framework-2.1.0.jar:2.1.0]
at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1487) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:69) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.MethodCall._eval(MethodCall.java:65) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Expression.eval(Expression.java:81) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.accept(DollarVariable.java:59) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:326) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:368) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
在当前的 moqui-framework 代码中(截至 2018 年 5 月 12 日,预发布版本 2.1.1-rc2 和之前的版本)使用视图实体作为另一个视图实体的成员仅支持子-selects(即具有属性member-entity.@sub-select="true")。不支持您尝试使用的快捷方式,只需加入您想要的所有普通实体作为成员实体。在这种情况下,您应该将 Party、Person 和 Organization 添加为成员实体,而不是使用 PartyDetail。
我有包含实体 A1(具有字段 A11、A12、...)、A2(具有字段 A21、A22)的视图实体 A 和包含实体 B1、B2 的视图实体 B。然后我想创建视图实体 C,其成员实体是 A 和 B,包括两个实体的所有字段。但是当我在视图实体 C 中使用 find() 方法时,moqui 将生成 SQL 语句,如:
Select A.A1.A11, A.A1.A12, ..... from .....
这使得SQL语句错误。我该如何解决这个问题???
这是我的代码:
<view-entity entity-name="PartyDetail" package="mantle.party">
<member-entity entity-alias="PTY" entity-name="mantle.party.Party"/>
<member-entity entity-alias="PER" entity-name="mantle.party.Person" join-from-alias="PTY" join-optional="true">
<key-map field-name="partyId"/></member-entity>
<member-entity entity-alias="ORG" entity-name="mantle.party.Organization" join-from-alias="PTY" join-optional="true">
<key-map field-name="partyId"/></member-entity>
<alias-all entity-alias="PTY"/>
<alias-all entity-alias="PER"/>
<alias-all entity-alias="ORG"/>
</view-entity>
<view-entity entity-name="UserAccountAndPartyDetail" package="moqui.view">
<member-entity entity-alias="UA" entity-name="moqui.security.UserAccount"></member-entity>
<member-entity entity-alias="PTY" entity-name="mantle.party.PartyDetail" join-from-alias="UA">
<key-map field-name="partyId"></key-map>
</member-entity>
<alias-all entity-alias="UA"></alias-all>
<alias-all entity-alias="PTY"></alias-all>
</view-entity>
而 UserAccountAndPartyDetail 的 SQL 语句是这样的:
select
UA.USER_ID,
UA.USERNAME,
UA.USER_FULL_NAME,
UA.CURRENT_PASSWORD,
UA.RESET_PASSWORD,
UA.PASSWORD_SALT,
UA.PASSWORD_HASH_TYPE,
UA.PASSWORD_BASE64,
UA.PASSWORD_SET_DATE,
UA.PASSWORD_HINT,
UA.HAS_LOGGED_OUT,
UA.DISABLED,
UA.DISABLED_DATE_TIME,
UA.SUCCESSIVE_FAILED_LOGINS,
UA.REQUIRE_PASSWORD_CHANGE,
UA.CURRENCY_UOM_ID,
UA.LOCALE,
UA.TIME_ZONE,
UA.EXTERNAL_USER_ID,
UA.EMAIL_ADDRESS,
UA.PARTY_ID,
PTY.PTY.PSEUDO_ID,
PTY.PTY.PARTY_TYPE_ENUM_ID,
PTY.PTY.EXTERNAL_ID,
PTY.PTY.DATA_SOURCE_ID,
PTY.PTY.GATEWAY_CIM_ID,
PTY.PTY.COMMENTS,
PTY.PTY.HAS_DUPLICATES,
PTY.PTY.LAST_DUP_CHECK_DATE,
PTY.PTY.MERGED_TO_PARTY_ID,
PTY.PER.SALUTATION,
PTY.PER.FIRST_NAME,
PTY.PER.MIDDLE_NAME,
PTY.PER.LAST_NAME,
PTY.PER.PERSONAL_TITLE,
PTY.PER.SUFFIX,
PTY.PER.NICKNAME,
PTY.PER.GENDER,
PTY.PER.BIRTH_DATE,
PTY.PER.DECEASED_DATE,
PTY.PER.HEIGHT,
PTY.PER.WEIGHT,
PTY.PER.MOTHERS_MAIDEN_NAME,
PTY.PER.MARITAL_STATUS_ENUM_ID,
PTY.PER.EMPLOYMENT_STATUS_ENUM_ID,
PTY.PER.RESIDENCE_STATUS_ENUM_ID,
PTY.PER.OCCUPATION,
PTY.ORG.ORGANIZATION_NAME,
PTY.ORG.OFFICE_SITE_NAME,
PTY.ORG.ANNUAL_REVENUE,
PTY.ORG.NUM_EMPLOYEES
from
(
USER_ACCOUNT UA
inner join(
select
PTY.PARTY_ID,
PTY.PSEUDO_ID,
PTY.PARTY_TYPE_ENUM_ID,
PTY.DISABLED,
PTY.EXTERNAL_ID,
PTY.DATA_SOURCE_ID,
PTY.GATEWAY_CIM_ID,
PTY.COMMENTS,
PTY.HAS_DUPLICATES,
PTY.LAST_DUP_CHECK_DATE,
PTY.MERGED_TO_PARTY_ID,
PER.SALUTATION,
PER.FIRST_NAME,
PER.MIDDLE_NAME,
PER.LAST_NAME,
PER.PERSONAL_TITLE,
PER.SUFFIX,
PER.NICKNAME,
PER.GENDER,
PER.BIRTH_DATE,
PER.DECEASED_DATE,
PER.HEIGHT,
PER.WEIGHT,
PER.MOTHERS_MAIDEN_NAME,
PER.MARITAL_STATUS_ENUM_ID,
PER.EMPLOYMENT_STATUS_ENUM_ID,
PER.RESIDENCE_STATUS_ENUM_ID,
PER.OCCUPATION,
ORG.ORGANIZATION_NAME,
ORG.OFFICE_SITE_NAME,
ORG.ANNUAL_REVENUE,
ORG.NUM_EMPLOYEES
from
(
PARTY PTY
left outer join PERSON PER on
PTY.PARTY_ID = PER.PARTY_ID
left outer join ORGANIZATION ORG on
PTY.PARTY_ID = ORG.PARTY_ID
)
) PTY on
UA.PARTY_ID = PTY.PTY.PARTY_ID
)
order by
1 offset 0 rows fetch first 50 rows only
这是控制台中的错误:
Error running groovy script (Error finding list of UserAccountAndPartyDetail by null [42P01]):
1 : import static org.moqui.util.ObjectUtilities.*
2 : import static org.moqui.util.CollectionUtilities.*
3 : import static org.moqui.util.StringUtilities.*
4 : import java.sql.Timestamp
5 : // these are in the context by default: ExecutionContext ec, Map<String, Object> context, Map<String, Object> result
6 : entityDefinition = (ec.entity.getEntityDefinition(selectedEntity))
7 : entityValueList_xafind = ec.entity.find("${selectedEntity}").offset(0).limit(50)
8 :
9 : if (true) {
10 : Map efSfiDefParms = null
11 : entityValueList_xafind.searchFormMap(ec.context, efSfiDefParms, "", "", true)
12 : }
13 : entityValueList = entityValueList_xafind.list()
14 : if (entityValueList_xafind.getLimit() == null) {
15 : entityValueListCount = entityValueList.size()
16 : entityValueListPageIndex = entityValueList.pageIndex
17 : entityValueListPageSize = entityValueListCount > 20 ? entityValueListCount : 20
18 : } else {
19 : entityValueListCount = entityValueList_xafind.count()
20 : entityValueListPageIndex = entityValueList_xafind.pageIndex
21 : entityValueListPageSize = entityValueList_xafind.pageSize
22 : }
23 : entityValueListPageMaxIndex = ((BigDecimal) (entityValueListCount - 1)).divide(entityValueListPageSize ?: (entityValueListCount - 1), 0, BigDecimal.ROUND_DOWN) as int
24 : entityValueListPageRangeLow = entityValueListPageIndex * entityValueListPageSize + 1
25 : entityValueListPageRangeHigh = (entityValueListPageIndex * entityValueListPageSize) + entityValueListPageSize
26 : if (entityValueListPageRangeHigh > entityValueListCount) entityValueListPageRangeHigh = entityValueListCount
27 : // make sure the last statement is not considered the return value
28 : return;
15:34:14.108 ERROR p60559178-15 o.m.i.s.ScreenRenderImpl Error rendering screen [component://tools/screen/Tools/Entity/DataEdit/EntityDataFind.xml]
org.moqui.impl.entity.EntitySqlException: Error finding list of UserAccountAndPartyDetail by null [42P01]
at org.moqui.impl.entity.EntityFindBase.listInternal(EntityFindBase.groovy:1064) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.list(EntityFindBase.groovy:929) ~[moqui-framework-2.1.0.jar:2.1.0]
at component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions.run(component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions:13) ~[script:?]
at org.moqui.impl.actions.XmlAction.run(XmlAction.java:67) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:132) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.doActualRender(ScreenRenderImpl.groovy:761) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.internalRender(ScreenRenderImpl.groovy:569) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.render(ScreenRenderImpl.groovy:147) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.webapp.MoquiServlet.service(MoquiServlet.groovy:95) ~[moqui-framework-2.1.0.jar:2.1.0]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) ~[moqui_temp7467403619005190592execlib_javax.servlet-api-3.1.0.jar.:3.1.0]
at org.moqui.elasticsearch.ElasticRequestLogFilter.doFilter(ElasticRequestLogFilter.groovy:107) ~[moqui-elasticsearch-1.1.0.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: org.postgresql.util.PSQLException: ERROR: invalid reference to FROM-clause entry for table "pty"
Hint: There is an entry for table "pty", but it cannot be referenced from this part of the query.
Position: 1898
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155) ~[postgresql-42.2.2.jar:42.2.2]
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118) ~[postgresql-42.2.2.jar:42.2.2]
at sun.reflect.GeneratedMethodAccessor25.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at org.postgresql.ds.PGPooledConnection$StatementHandler.invoke(PGPooledConnection.java:428) ~[postgresql-42.2.2.jar:42.2.2]
at com.sun.proxy.$Proxy22.executeQuery(Unknown Source) ~[?:?]
at bitronix.tm.resource.jdbc.proxy.PreparedStatementJavaProxy.executeQuery(PreparedStatementJavaProxy.java:102) ~[btm-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
at org.moqui.impl.entity.EntityQueryBuilder.executeQuery(EntityQueryBuilder.java:91) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindImpl.iteratorExtended(EntityFindImpl.java:150) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.listInternal(EntityFindBase.groovy:1063) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.entity.EntityFindBase.list(EntityFindBase.groovy:929) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.entity.EntityFind$list.call(Unknown Source) ~[?:?]
at component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions.run(component___tools_screen_Tools_Entity_DataEdit_EntityDataFind_xml_screen_actions:13) ~[script:?]
at org.moqui.impl.actions.XmlAction.run(XmlAction.java:67) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:132) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) ~[moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) [moqui-framework-2.1.0.jar:2.1.0]
at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1487) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:69) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.MethodCall._eval(MethodCall.java:65) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Expression.eval(Expression.java:81) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.accept(DollarVariable.java:59) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.recurse(Environment.java:824) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.RecurseNode.accept(RecurseNode.java:73) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.recurse(Environment.java:824) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.RecurseNode.accept(RecurseNode.java:73) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invokeNodeHandlerFor(Environment.java:626) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.VisitNode.accept(VisitNode.java:71) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:326) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:332) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.process(Environment.java:305) [freemarker-2.3.26-incubating.jar:2.3.26]
at org.moqui.impl.screen.ScreenWidgets.render(ScreenWidgets.groovy:40) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.renderSingle(ScreenSection.groovy:139) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenSection.render(ScreenSection.groovy:112) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenDefinition.render(ScreenDefinition.groovy:509) [moqui-framework-2.1.0.jar:2.1.0]
at org.moqui.impl.screen.ScreenRenderImpl.renderSubscreen(ScreenRenderImpl.groovy:972) [moqui-framework-2.1.0.jar:2.1.0]
at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at freemarker.ext.beans.BeansWrapper.invokeMethod(BeansWrapper.java:1487) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.ext.beans.SimpleMethodModel.exec(SimpleMethodModel.java:69) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.MethodCall._eval(MethodCall.java:65) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Expression.eval(Expression.java:81) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.DollarVariable.accept(DollarVariable.java:59) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:326) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.visit(Environment.java:368) [freemarker-2.3.26-incubating.jar:2.3.26]
at freemarker.core.Environment.invoke(Environment.java:714) [freemarker-2.3.26-incubating.jar:2.3.26]
在当前的 moqui-framework 代码中(截至 2018 年 5 月 12 日,预发布版本 2.1.1-rc2 和之前的版本)使用视图实体作为另一个视图实体的成员仅支持子-selects(即具有属性member-entity.@sub-select="true")。不支持您尝试使用的快捷方式,只需加入您想要的所有普通实体作为成员实体。在这种情况下,您应该将 Party、Person 和 Organization 添加为成员实体,而不是使用 PartyDetail。