Sobes.tech
Junior — Middle

Have you used pure SQL for writing queries without using ORM or other abstractions?

sobes.tech AI

Answer from AI

Yes, I have used raw SQL for writing queries without ORM. This is useful when maximum performance is needed or for complex queries that are difficult to express through ORM. For example, to fetch data with multiple JOINs and aggregate functions, you can write the query directly:

SELECT u.id, u.name, COUNT(o.id) AS orders_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
GROUP BY u.id, u.name
HAVING orders_count > 5
ORDER BY orders_count DESC;

In Java, such a query can be executed via JDBC, using PreparedStatement for security and parameterization.

Have you used pure SQL for writing queries without… - sobes.tech