As mentioned in the documentation, JpaRepository lets us write native SQL queries. So, I wrote 2 different versions of the same query.
Version 1:
@Query(value = "SELECT b FROM branch AS b where b.companyId = ?1")
List<Branch> findByCompanyId(Long companyId);
Version 2:
@Query(nativeQuery = true, value = "SELECT * FROM branch where b.company_id = ?1")
List<Branch> findByCompanyId(Long companyId);
Both versions output the same results, I would like to know if there is a performance difference between these methods? Which method is recommended? What is the best practice?