我有以下方法可以正常工作,但是无论何时从调用方法中被调用,都以字母顺序返回对象:-
public List<Object> getExportDataFromView() {
try {
String selectQuery = "SELECT UNIQUE_ID, DATE, CODE, PRODUCT_CODE, "
+ " MESSAGE AS MESSAGE_TEXT, SOURCE, COMPANY_ID, REMARK, BATCH, COUNTRY, PRODUCT_CODE_SCHEME, EXTERNAL_TRANSACTION_ID, RETURN_CODE, CORRELATION_ID, BUSINESS_PROCESS, BATCH_EXPIRY_DATE "
+ " FROM \"test\".\"my-systems.Company::views.Export_Data_View\" "
+ " WHERE COMPANY_ID = 'C100' "
+ " ORDER BY DATE DESC";
Query q = this.em.createNativeQuery(selectQuery, ExportData.class);
return q.getResultList();
} catch (Exception e) {
return null;
} finally {
this.em.close();
}
}
无论何时从另一个调用方法中调用此方法,返回的列表都是按排序顺序(按字母顺序)。但是,在ExportData.java的JPA Entity类中,以原始顺序声明字段,如下所示:-
@Entity
@Table(name = "\"my-systems.Company::views.Export_Data_View\"", schema="\"test\"")
public class ExportData implements Serializable {
private static final long serialVersionUID = 1L;
@Id
private String UNIQUE_ID;
private String CODE;
private String PRODUCT_CODE;
private String MESSAGE_TEXT;
private String SOURCE;
有什么方法可以保持与Entity类中声明的顺序相同,而不是在不更改返回类型(即列表)的情况下进行排序。
任何帮助将不胜感激。
谢谢