i am working on Jpa Native query,
I want all my all send with it count but this my query
select id,status,COUNT(*) as count from tb_abc where sender_id=?1 group by status
But problem is when i will run it on Mysql then it will run fine but when i will run using java code i.e native query then then count is return null or 0..
This my class which i have map from query
This Native Query
@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;
}
}
and TableABC class is as:
public class 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;
}
}
Please help me ...