如何解决UNION在Spring数据JPA原生查询两张表
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.finder"
>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.SYstem_ALERT_WINDOW"/>
<application
android:name=".MainApplication"
android:networkSecurityConfig="@xml/network_security_config"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:allowBackup="false"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.broWSABLE" />
<data android:scheme="finder" />
</intent-filter>
</activity>
<activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
<!-- You will only need to add this Meta-data tag,but make sure it's a child of application -->
<Meta-data
android:name="com.google.android.geo.API_KEY"
android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
<!-- You will also only need to add this uses-library tag -->
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
</application>
例如:txrh_bcaterms UNION txrm_bcaterms
I have a requirement where i need to fetch number of record both the table using JPA native UNION query for Pagination
table 1=>txrh_bcaterms
table 2=> txrm_bcaterms
注意:实际上stepid是txrh_bcaterms表的主键,txrm_bcaterms表中没有stepid
错误 ------- 在 ui 中我通过了机构 =BC/AC/EC 然后 UNION 查询能够执行和获取数据 但如果我通过了 SC,则低于异常
@Query(nativeQuery = true,value= "SELECT "
+ " customerid,"
+ "finance_type,"
----------
-------etc----
+ "institution,"
+ "limit_groupid,"
+ "tx_booking_location,"
+ "finance_tenor_days,"
+ "margin_type,"
+ "additional_margin_percentage,"
+ "margin_percentage,"
+ "stale_document_condition_proforma_fin,"
+ "customer_name "
+ "from "
+ "txrh_bcaterms "
+ "where "
+ " institution=:institution "
+ "AND tx_booking_location=:txBookingLocation "
+ "OR finance_type=:financeType "
+ "OR customerid=:customerID "
+ "OR limit_groupid=:limitGroupID "
+ "UNION "
+ "SELECT "
+ "customerid,"
----------
-------etc----
+ "institution,"
+" finance_tenor_days,"
+ "stale_document_condition_proforma_fin,"
+ "customer_name "
+ "from txrm_bcaterms "
"
+ " institution=:institution "
+ "AND tx_booking_location=:txBookingLocation "
+ "OR finance_type=:financeType "
+ "OR customerid=:customerID "
+ "OR limit_groupid=:limitGroupID "
)
Page<Map<String,Object>> historyAndMaster(@Param("institution") String institution,@Param("txBookingLocation") String txBookingLocation,@Param("financeType") String financeType,@Param("customerID") String customerID,@Param("limitGroupID") String limitGroupID,Pageable page);
=>如果列数不同,那么它是如何工作的 BC/AC/EC
Caused by ERROR: each UNION query must have the same number of columns
Position: 581
at org.axonframework.axonserver.connector.ErrorCode.lambda$static$15(ErrorCode.java:107)
... 9 common frames omitted
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。