I have two table. Post and comments
create table posts
(
id bigint not null primary key,
description varchar(8192),
published_date timestamp(6),
title varchar(255)
);
create table comments
(
id bigserial primary key,
comment varchar(255),
created_date timestamp(6),
post_id bigint constraint fkh4c7lvsc298whoyd4w9ta25cr references posts
);
and i want to generate this sql query using jpa criteria api:
select count(*)
from (select count(c.*) comment_count, p.*
from posts p
left join comments c on p.id = c.post_id
group by p.id
having count(c.*) > 1) t
this is my a year problem )(. Thank you in advance!
java code with jpa criteria api