0

私はJPAネイティブクエリに取り組んでいます、

私はすべてのすべての送信をカウントしたいのですが、これは私のクエリです

select id,status,COUNT(*) as count from tb_abc where sender_id=?1 group by status

しかし、問題は、Mysqlで実行すると正常に実行されますが、Javaコード、つまりネイティブクエリを使用して実行すると、カウントがnullまたは0を返すことです..

これは、クエリからマップした私のクラスです

このネイティブ クエリ

@Repository public class PatientAppointmentNativeDao {

@PersistenceContext
private EntityManager em;

public List<TableAbc> get(Long senderId) {

    @SuppressWarnings("unchecked")
    List<TableAbc> resultData = (List<TableAbc>) em
            .createNativeQuery(
                    "select *,COUNT(*) as count from tb_abc where sender_id=?1 group by status",
                    com.abc.TableAbc.class)
            .setParameter(1, senderId)
            .getResultList();

    return resultData;
}

}

TableABC クラスは次のとおりです。

パブリッククラスPatientAppointment {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;



@ManyToOne
private Sender sender;

private Integer status;


@Transient
private int countTotal;

public int getCountTotal() {
    return countTotal;
}

public void setCountTotal(int countTotal) {
    this.countTotal = countTotal;
}

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}




public Integer getStatus() {
    return status;
}

public void setStatus(Integer status) {
    this.status = status;
}

}

私を助けてください ...

4

0 に答える 0