Junior — Middle
Have you had experience working with databases without ORM tools like Hibernate?
sobes.tech AI
Answer from AI
Yes, I have experience working with databases without ORM. In such cases, interaction occurs directly through JDBC (Java Database Connectivity) or similar low-level APIs.
This means that the developer writes SQL queries manually, manages connections, processes results, and converts data from ResultSet into objects by hand.
Example of a simple query without ORM:
Connection conn = DriverManager.getConnection(dbUrl, user, password);
PreparedStatement stmt = conn.prepareStatement("SELECT id, name FROM users WHERE id = ?");
stmt.setInt(1, 10);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
int id = rs.getInt("id");
String name = rs.getString("name");
// Manually create object
User user = new User(id, name);
}
rs.close();
stmt.close();
conn.close();
This approach gives full control over SQL and performance but requires more code and attention to resource management.