MySQL inner join error : During the execution of the query was detected to be null. Primary keys must not contain null

MySQL inner join error : During the execution of the query was detected to be null. Primary keys must not contain null

我想关联两个 table 上的特定列,并根据时间戳取回匹配值,即同时发生但写在两个不同 table 上的事件。我正在使用 MYSQL INNER JOINS 如下:

到目前为止,我的查询如下所示:

   String threatQueryJoin = "SELECT awsevents.ALERT.resourceName, awsevents.RECORD.Record_Id,awsevents.RECORD.resourceName, "
            + "awsevents.ALERT.alert_id FROM awsevents.ALERT inner join awsevents.RECORD on awsevents.ALERT.resourceName "
            + "= awsevents.RECORD.resourceName where (awsevents.ALERT.timeStamp >= '2019-05-10' AND awsevents.RECORD.timeStamp >= '2019-05-10') "
            + "AND (awsevents.ALERT.resourceName='company-checker-log-963f5e78-0dea-46f1-9a48-5a116bdae350' "
            + "AND awsevents.RECORD.resourceName='company-checker-log-963f5e78-0dea-46f1-9a48-5a116bdae350') order by awsevents.RECORD.timeStamp";
    Query q = AWSEventsDAO.em.createNativeQuery(threatQueryJoin);

List ll = q.getResultList();

MySQL workbench 中查询的响应看起来不错:

不过,我想把结果写入另一个table。由于我不精通MySQL,我很高兴知道是否有更好的方法来处理此类查询。使用 inner join,出现以下错误:

Exception Description: The primary key read from the row [ArrayRecord(
 => company-checker-log-963f5e78-0dea-46f1-9a48-5a116bdae350
 => 45167
 => company-checker-log-963f5e78-0dea-46f1-9a48-5a116bdae350
 => 8108)] during the execution of the query was detected to be null.  Primary keys must not contain null.

我已经通过删除 mapped classRecord.class 并使用

解决了这个问题
Object[] alert = threatList.get(i);

tutorialsjpanative queries 所示。结果是 EntityManager returns 一个 List of Object[] 需要在之后处理。