Hibernate execute JDBC statement takes longer than it should

Hi Team.
I discovered that when a particular query is executed by hibernate, it takes much longer than if I take the generated sql and run it in a sql client.
for example, after enabled hibernate statics, I can see in the log

67839913762 nanoseconds spent executing 2 JDBC statements; which equals 1.13 minutes

However, if I take the generated sql and run it, it only takes max of 1.5 seconds.

Can anybody points me to what are the possible cause of this difference?
My understanding is, the time for executing the JDBC statement is entirely up to the DB right?
If the SQL is the same, how come it’s so slow when it’s executed by hibernate?

Usually, Hibernate operations not only execute the query, but also fetch all the results and materialize objects from that. If you “just” execute the statement, you are not doing the same work that Hibernate does.
Also, do you use parameters with Hibernate but literals in your SQL? That makes a big difference for many DBs. It also makes a difference if you ran the query before, because the DB caches data.

thanks for replying!!

What bothers me is I think this might be because of something wrong with the database view we are trying to hit. But if I take the hibernate generated sql and run it in other sql clients, the response time is less than 1.5 seconds. The code is simple, no joins or anything, you can find the example below. I also tested the pageable request with different sizes, 1,10,100, no matter the size, when executed by hibernate, it takes much longer.
Which makes me wonder, is it possible that the database(in this case, oracle), can deprioritize jdbc connection from hibernate? Otherwise, I don’t have any other explaination

samle entity class

@Entity
@Data
@AllArgsConstructor
@Builder
public class GpCustomer {
  @Id
  @Column(name = "CUSTNO")
  private String custno;

  @Column(name = "COMPANY")
  private String company;
}

sample repository

@Repository
public interface GpCustomerRepository extends JpaRepository<GpCustomer, String> {}

sample service

 public Page<GpCustomer> findAllCustomers() {
    Pageable limit = PageRequest.of(0,10);
    return GpCustomerRepository.findAll(limit);
  }

Update:
hibernate statistics

Session Metrics {
    137214920 nanoseconds spent acquiring 1 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    18734658 nanoseconds spent preparing 2 JDBC statements;
    67839913762 nanoseconds spent executing 2 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    16386 nanoseconds spent executing 2 partial-flushes (flushing a total of 0 entities and 0 collections)
}

The statistics say that 2 queries are executed. Did you check if the second query might be the cause for the delay?