I am using JPA in my project.
I came to a query in which I need to make join operation on five tables. So I created a native query which returns five fields.
if you are using Spring, you can use org.springframework.jdbc.core.RowMapper
Here is an example:
public List query(String objectType, String namedQuery)
{
String rowMapper = objectType + "RowMapper";
// then by reflection you can instantiate and use. The RowMapper classes need to follow the naming specific convention to follow such implementation.
}