Я пишу запрос соединения, используя entityManager.createNativeQuery (somequery) в пользовательском методе jpa, когда я запускаю код, я получаю следующую ошибку:
com.ibm.db2.jcc.am.SqlException: [jcc] [10150] [10300] [4.12.56] Invalid> параметр: неизвестное имя столбца exc_seq_nbr. ERRORCODE = -4460, SQLSTATE = null
Я использую сервер IBM DB2 и весеннюю загрузку
exceptionTenderPK (объект в классе сущности) отображается неправильно, поэтому, получив недопустимый столбец, кто-нибудь может подсказать, как отобразить класс объекта exceptionTenderPK
Примечание: в этом случае я не могу использовать @OneToMany, потому что таблицы не связаны
@Entity
@Table(name = "EPT_TNDR_EXC")
@SqlResultSetMapping(
name = "exceptionTenderMapping",
entities = {
@EntityResult(
entityClass = ExceptionTender.class,
fields = {
@FieldResult(name = "exceptionTenderPK.salesDate", column = "SLS_DTE")
,@FieldResult(name = "exceptionTenderPK.storeNumber", column = "STR_NBR")
,@FieldResult(name = "exceptionTenderPK.registerNumber", column = "RGST_ID")
,@FieldResult(name = "exceptionTenderPK.transactionNumber", column = "TRN_NBR")
,@FieldResult(name = "exceptionTenderPK.startTime", column = "STRT_TM")
,@FieldResult(name = "exceptionTenderPK.exceptionSequenceNumber", column = "EXC_SEQ_NBR")
,@FieldResult(name = "tenderAmount", column = "TNDR_AMT")
,@FieldResult(name = "tndrId", column = "TNDR_ID")
,@FieldResult(name = "reason", column = "EXC_RSN_CDE")
,@FieldResult(name = "completionIndicator", column = "CPL_IND")
,@FieldResult(name = "userId", column = "LAST_UPD_USR_ID")
,@FieldResult(name = "lastUpdatedTmst", column = "LAST_UPD_TMST")
,@FieldResult(name = "excTrnSrcCde", column = "EXC_TRN_SRC_CDE")
,@FieldResult(name = "excTrnStatCde", column = "EXC_TRN_STAT_CDE")
})
})
@Data
public class ExceptionTender {
@EmbeddedId
@JsonProperty(value = "exceptionTenderPK")
private ExceptionTenderPK exceptionTenderPK;
@Column(name = "TNDR_AMT")
@JsonProperty(value = "TNDR_AMT")
private BigDecimal tenderAmount;
@Column(name = "TNDR_ID")
@JsonProperty(value = "TNDR_ID")
private String tndrId;
@Column(name = "EXC_RSN_CDE")
@JsonProperty(value = "EXC_RSN_CDE")
private String reason;
@Column(name = "CPL_IND")
@JsonProperty(value = "CPL_IND")
private String completionIndicator;
@Column(name = "LAST_UPD_USR_ID")
@JsonProperty(value = "LAST_UPD_USR_ID")
private String userId;
@Column(name = "LAST_UPD_TMST")
@JsonProperty(value = "LAST_UPD_TMST")
private Date lastUpdatedTmst;
@Column(name = "EXC_TRN_SRC_CDE")
@JsonProperty(value = "EXC_TRN_SRC_CDE")
private String excTrnSrcCde;
@Column(name = "EXC_TRN_STAT_CDE")
@JsonProperty(value = "EXC_TRN_STAT_CDE")
private String excTrnStatCde;
@Transient
@QueryType(PropertyType.STRING)
private String statusCode;
}
@Transactional
public interface JoinQueryRepository extends JpaRepository<ExceptionTender, Long>, JoinQueryRepositoryCustom{
}
public interface JoinQueryRepositoryCustom {
List<ExceptionTender> getGRDetails(ExceptionTender et,Date reportDate);
}
public class JoinQueryRepositoryImpl implements JoinQueryRepositoryCustom {
@PersistenceContext
EntityManager entityManager;
@SuppressWarnings("all")
@Override
public List<ExceptionTender> getGRDetails(ExceptionTender et,Date reportDate) {
String queryStr = "select et.SLS_DTE from db272dba.ept_tndr_exc et"
+ " join db272dba.EPT_TNDR_EXC_RPT_DTE etr on et.SLS_DTE = etr.SLS_DTE where et.STR_NBR =? ";
List<ExceptionTender> grDetailsList = null;
Query query = entityManager.
createNativeQuery(queryStr,"exceptionTenderMapping")
.setParameter(1, 222);
grDetailsList = query.getResultList();
return grDetailsList;
}
}